pub trait WireWrite {
fn write_wire<const E: bool>(
&self,
curs: &mut WireCursorMut<'_>
) -> Result<(), WireError>;
}Expand description
Serialization from a data type to the wire.
A type that implements this trait guarantees that it can be serialized into a
number of bytes that will be written to the provided WireCursorMut. If the
bytes cannot be written to the wire, an error will be returned.
Required Methods§
sourcefn write_wire<const E: bool>(
&self,
curs: &mut WireCursorMut<'_>
) -> Result<(), WireError>
fn write_wire<const E: bool>(
&self,
curs: &mut WireCursorMut<'_>
) -> Result<(), WireError>
Serializes the data type into a number of bytes on the wire, or returns a WireError on failure.
The generic boolean E designates the intended endianness of the data being written. If E is set to
true, then the data will be serialized in big endian format; if false, it will be serialized
in little endian.
Errors
WireError::InsufficientBytes - not enough bytes remained on the cursor to write the type to the wire.
WireError::Internal - an internal error occurred in the wire-rs library