Trait ToBytes

Source
pub trait ToBytes: Sized {
    // Required method
    fn to_bytes(&self, writer: &mut dyn Write) -> Result<(), Error>;
}
Expand description

ToBytes indicates that the type can be directly translated to a byte-oriented format. This is primarily used for types that represent structures used in a wire format.

Required Methods§

Source

fn to_bytes(&self, writer: &mut dyn Write) -> Result<(), Error>

Write an instance of this type to the writer.

If an error occurs, the error is returned and writer is left in an indeterminate state.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§