fn prepend_length(data: Vec<u8>) -> Result<Vec<u8>, Error> {
    if data.len() > 65535 {
      return Err(Error::GenerateError);
    }

    let length = u16::try_from(data.len() & 0xFFFF)
      .unwrap()
      .to_be_bytes()
      .to_vec();

    Ok([&length[..], &data[..]].concat())
  }
/// Used by to_vec() for calculating length for strings, string pairs, and binary data.
/// The length of arrays is limited to the range of 0 to 65,535 bytes. Because of that we
/// need to convert usize to a two byte u8 array.
Used by to_vec() for calculating length for strings, string pairs, and binary data.
The length of arrays is limited to the range of 0 to 65,535 bytes. Because of that we
need to convert usize to a two byte u8 array.
Used by to_vec () for calculating length for strings string pairs and binary data . The length of arrays is limited to the range of 0 to 65 535 bytes . Because of that we need to convert usize to a two byte u8 array .
fn prepend_length(data: Vec<u8>) -> Result<Vec<u8>, Error> {
    if data.len() > 65535 {
      return Err(Error::GenerateError);
    }
    let length = u16::try_from(data.len() & 0xFFFF)
      .unwrap()
      .to_be_bytes()
      .to_vec();
    Ok([&length[..], &data[..]].concat())
  }
fn prepend_length ( data : Vec < u8 > ) -> Result < Vec < u8 > , Error > { if data . len ( ) > 65535 { return Err ( Error :: GenerateError ) ; } let length = u16 :: try_from ( data . len ( ) & 0xFFFF ) . unwrap ( ) . to_be_bytes ( ) . to_vec ( ) ; Ok ( [ & length [ .. ] , & data [ .. ] ] . concat ( ) ) }
Used by to_vec() for calculating length for strings, string pairs, and binary data.
Used by to_vec () for calculating length for strings string pairs and binary data .
data
Vec<u8>
data
Vec<u8>