Skip to main content

WireFormat

Trait WireFormat 

Source
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§

Source

fn required_size(&self) -> usize

Returns the number of bytes required to serialize this value.

Source

fn encode<T: Write>(&self, writer: &mut T) -> Result<usize, Error>

Serialize a value to a byte stream. Returns the number of bytes written.

§Errors
  • If the data cannot be written to the stream

Provided Methods§

Source

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.

Implementors§

Source§

impl WireFormat for Entry

Source§

impl WireFormat for EventGroupEntry

Source§

impl WireFormat for simple_someip::protocol::sd::Header<'_>

Source§

impl WireFormat for ServiceEntry

Source§

impl WireFormat for simple_someip::protocol::Header

Source§

impl<PayloadDefinition: PayloadWireFormat> WireFormat for Message<PayloadDefinition>