pub trait ToBytes {
// Required method
fn to_bytes(&self, buf: &mut [u8]) -> Result<usize, ParseError>;
}Expand description
Serialize a type into a byte slice, returning the number of bytes written.
Unlike WriteToBytes, this trait does not require std::io or the byteorder crate.
It operates directly on &mut [u8] slices, making it suitable for no_std environments.
Required Methods§
Sourcefn to_bytes(&self, buf: &mut [u8]) -> Result<usize, ParseError>
fn to_bytes(&self, buf: &mut [u8]) -> Result<usize, ParseError>
Write this value into the given byte slice. Returns the number of bytes
written. Fails with ParseError::BufferTooShort if buf is too short.