pub trait BufferSerializer: Sized {
// Required method
fn serialize(&self, buf: &mut &[u8]) -> Result<usize>;
}
Expand description
A trait for serializing objects to an octet buffer.
Required Methods§
Sourcefn serialize(&self, buf: &mut &[u8]) -> Result<usize>
fn serialize(&self, buf: &mut &[u8]) -> Result<usize>
Serializes self
into the given mutable octet buffer.
§Parameters
buf
: A mutable reference to a octet slice that will be populated with serialized data.
§Returns
This method returns a Result<usize>
, which is:
Ok(usize)
representing the number of octets written to the buffer on success.Err(io::Error)
if serialization fails, which could occur due to issues with writing to the buffer.
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.