pub trait ToBytes {
    fn to_bytes(&self) -> Result<Vec<u8>, Error>;

    fn write_bytes(&self, dst: &mut [u8]) -> Result<usize, Error> { ... }
}
Expand description

Serialize a type into a sequence of bytes with unspecified endianness. The implementations for the built-in types are in big endian for this trait.

Required methods

Serialize into a newly-allocated byte vector.

Provided methods

Serialize into an existing mutable byte slice. The usize Result contains how many bytes were written to dst.

Implementations on Foreign Types

Implementors