pub trait WireFormat:
Send
+ Sized
+ Sync {
// Required methods
fn required_size(&self) -> usize;
fn encode<T: Write>(&self, writer: &mut T) -> Result<usize, Error>;
// Provided method
fn encode_to_slice(&self, buf: &mut [u8]) -> Result<usize, Error> { ... }
}Expand description
A trait for types that can be serialized to a Writer.
WireFormat acts as the base trait for all types that can be serialized
as part of the Simple SOME/IP ecosystem. Decoding is handled by zero-copy
view types (HeaderView, MessageView, etc.) instead of this trait.
Required Methods§
Sourcefn required_size(&self) -> usize
fn required_size(&self) -> usize
Returns the number of bytes required to serialize this value.
Provided Methods§
Sourcefn encode_to_slice(&self, buf: &mut [u8]) -> Result<usize, Error>
fn encode_to_slice(&self, buf: &mut [u8]) -> Result<usize, Error>
Encode into a byte slice, returning the number of bytes written.
§Errors
Returns an error if buf is too small (requires at least
required_size() bytes).
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.