Skip to main content

ToBytes

Trait ToBytes 

Source
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§

Source

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.

Implementations on Foreign Types§

Source§

impl ToBytes for (LeapIndicator, Version, Mode)

Source§

fn to_bytes(&self, buf: &mut [u8]) -> Result<usize, ParseError>

Implementors§