pub fn generate(&self) -> Result<Vec<u8>, Error> {
    // create a vector to hold the generated data
    let mut props = vec![];

    // PartialOrd sorts enum variants in the order they are declared.
    for (key, value) in self.values.iter() {
      let id: u8 = u8::from(*key);
      props.push(vec![id]);
      props.push(value.to_vec()?);
    }

    let bytes = props.concat();

    // we need to fit the usize into a u16, so we can grab the first two bytes
    let length = u16::try_from(bytes.len() & 0xFFFF)
      .unwrap()
      .to_be_bytes()
      .to_vec();

    let result = vec![length, bytes];

    Ok(result.concat())
  }
/// Convert Property values into a byte vector.
Convert Property values into a byte vector.
Convert Property values into a byte vector .
pub fn generate(&self) -> Result<Vec<u8>, Error> {
    // create a vector to hold the generated data
    let mut props = vec![];
    // PartialOrd sorts enum variants in the order they are declared.
    for (key, value) in self.values.iter() {
      let id: u8 = u8::from(*key);
      props.push(vec![id]);
      props.push(value.to_vec()?);
    }
    let bytes = props.concat();
    // we need to fit the usize into a u16, so we can grab the first two bytes
    let length = u16::try_from(bytes.len() & 0xFFFF)
      .unwrap()
      .to_be_bytes()
      .to_vec();
    let result = vec![length, bytes];
    Ok(result.concat())
  }
pub fn generate ( & self ) -> Result < Vec < u8 > , Error > { // create a vector to hold the generated data let mut props = vec ! [ ] ; // PartialOrd sorts enum variants in the order they are declared. for ( key , value ) in self . values . iter ( ) { let id : u8 = u8 :: from ( * key ) ; props . push ( vec ! [ id ] ) ; props . push ( value . to_vec ( ) ? ) ; } let bytes = props . concat ( ) ; // we need to fit the usize into a u16, so we can grab the first two bytes let length = u16 :: try_from ( bytes . len ( ) & 0xFFFF ) . unwrap ( ) . to_be_bytes ( ) . to_vec ( ) ; let result = vec ! [ length bytes ] ; Ok ( result . concat ( ) ) }
Convert Property values into a byte vector.
Convert Property values into a byte vector .
&self
&self