pub fn to_vec(&self) -> Result<Vec<u8>, Error> {
    let bytes = match self {
      Self::Byte(value) => value.to_be_bytes().to_vec(),
      Self::TwoByteInteger(value) => value.to_be_bytes().to_vec(),
      Self::FourByteInteger(value) => value.to_be_bytes().to_vec(),
      Self::VariableByteInteger(value) => Self::encode_variable_byte(value)?,
      Self::Utf8EncodedString(value) => Self::prepend_length(value.as_bytes().to_vec())?,
      Self::BinaryData(value) => Self::prepend_length(value.to_vec())?,
      Self::Utf8StringPair(one, two) => [
        Self::prepend_length(one.as_bytes().to_vec())?,
        Self::prepend_length(two.as_bytes().to_vec())?,
      ]
      .concat(),
    };

    Ok(bytes)
  }
/// Convert DataType variants into u8 vectors.
Convert DataType variants into u8 vectors.
Convert DataType variants into u8 vectors .
pub fn to_vec(&self) -> Result<Vec<u8>, Error> {
    let bytes = match self {
      Self::Byte(value) => value.to_be_bytes().to_vec(),
      Self::TwoByteInteger(value) => value.to_be_bytes().to_vec(),
      Self::FourByteInteger(value) => value.to_be_bytes().to_vec(),
      Self::VariableByteInteger(value) => Self::encode_variable_byte(value)?,
      Self::Utf8EncodedString(value) => Self::prepend_length(value.as_bytes().to_vec())?,
      Self::BinaryData(value) => Self::prepend_length(value.to_vec())?,
      Self::Utf8StringPair(one, two) => [
        Self::prepend_length(one.as_bytes().to_vec())?,
        Self::prepend_length(two.as_bytes().to_vec())?,
      ]
      .concat(),
    };
    Ok(bytes)
  }
pub fn to_vec ( & self ) -> Result < Vec < u8 > , Error > { let bytes = match self { Self :: Byte ( value ) => value . to_be_bytes ( ) . to_vec ( ) , Self :: TwoByteInteger ( value ) => value . to_be_bytes ( ) . to_vec ( ) , Self :: FourByteInteger ( value ) => value . to_be_bytes ( ) . to_vec ( ) , Self :: VariableByteInteger ( value ) => Self :: encode_variable_byte ( value ) ? , Self :: Utf8EncodedString ( value ) => Self :: prepend_length ( value . as_bytes ( ) . to_vec ( ) ) ? , Self :: BinaryData ( value ) => Self :: prepend_length ( value . to_vec ( ) ) ? , Self :: Utf8StringPair ( one , two ) => [ Self :: prepend_length ( one . as_bytes ( ) . to_vec ( ) ) ? , Self :: prepend_length ( two . as_bytes ( ) . to_vec ( ) ) ? , ] . concat ( ) , } ; Ok ( bytes ) }
Convert DataType variants into u8 vectors.
Convert DataType variants into u8 vectors .
&self
&self