Skip to main content

PayloadWireFormat

Trait PayloadWireFormat 

Source
pub trait PayloadWireFormat:
    Debug
    + Send
    + Sized
    + Sync {
    type SdHeader: WireFormat + Clone + Debug + Eq;

    // Required methods
    fn message_id(&self) -> MessageId;
    fn as_sd_header(&self) -> Option<&Self::SdHeader>;
    fn from_payload_bytes(
        message_id: MessageId,
        payload: &[u8],
    ) -> Result<Self, Error>;
    fn new_sd_payload(header: &Self::SdHeader) -> Self;
    fn sd_flags(&self) -> Option<Flags>;
    fn required_size(&self) -> usize;
    fn encode<T: Write>(&self, writer: &mut T) -> Result<usize, Error>;
}
Expand description

A trait for SOME/IP Payload types that can be serialized to a Writer and constructed from raw payload bytes.

Note that SOME/IP payloads are not self identifying, so the Message ID must be provided by the caller.

Required Associated Types§

Source

type SdHeader: WireFormat + Clone + Debug + Eq

The SD header type used by this payload implementation.

Required Methods§

Source

fn message_id(&self) -> MessageId

Get the Message ID for the payload

Source

fn as_sd_header(&self) -> Option<&Self::SdHeader>

Get the payload as a service discovery header

Source

fn from_payload_bytes( message_id: MessageId, payload: &[u8], ) -> Result<Self, Error>

Construct a payload from raw bytes and a message ID.

§Errors
  • If the message ID is not supported
  • If the payload bytes cannot be parsed
Source

fn new_sd_payload(header: &Self::SdHeader) -> Self

Create a PayloadWireFormat from a service discovery Header

Source

fn sd_flags(&self) -> Option<Flags>

Return the SD flags if this payload is a service discovery message.

Source

fn required_size(&self) -> usize

Number of bytes required to write the payload

Source

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

Serialize the payload to a Writer

§Errors

Returns an error if the payload cannot be written to the writer.

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§