Skip to main content

PayloadWireFormat

Trait PayloadWireFormat 

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

Show 13 methods // 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>; fn new_subscription_sd_header( service_id: u16, instance_id: u16, major_version: u8, ttl: u32, event_group_id: u16, client_ip: Ipv4Addr, protocol: TransportProtocol, client_port: u16, reboot_flag: RebootFlag, ) -> Self::SdHeader; // Provided methods fn set_reboot_flag(_header: &mut Self::SdHeader, _reboot: RebootFlag) { ... } fn for_each_offered_endpoint<F>(&self, _f: F) where F: FnMut(OfferedEndpoint) { ... } fn for_each_service_instance<F>(&self, _f: F) where F: FnMut(u16, u16) { ... } fn offered_endpoints(&self) -> Vec<OfferedEndpoint> { ... } fn service_instances(&self) -> Vec<(u16, u16)> { ... }
}
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.

Source

fn new_subscription_sd_header( service_id: u16, instance_id: u16, major_version: u8, ttl: u32, event_group_id: u16, client_ip: Ipv4Addr, protocol: TransportProtocol, client_port: u16, reboot_flag: RebootFlag, ) -> Self::SdHeader

Construct an SD header for subscribing to an event group.

Provided Methods§

Source

fn set_reboot_flag(_header: &mut Self::SdHeader, _reboot: RebootFlag)

Override the reboot flag on an SD header in-place.

Used by Client::sd_announcements_loop to refresh the reboot flag per-tick from the client’s tracked state. Defaults to a no-op so payload types that never participate in SD reboot tracking (e.g. RawPayload for static-only SD use) don’t have to provide an impl that will never be called.

Source

fn for_each_offered_endpoint<F>(&self, _f: F)

Visit each offered / stopped service endpoint in this SD payload with f.

Visitor pattern (rather than returning a Vec) so the trait is no_std-compatible: the implementation walks its internal SD entries and invokes f for each OfferedEndpoint. The Client run loop uses this to auto-populate its service registry from inbound discovery messages.

The default implementation visits nothing — payload types that don’t carry SD entries (e.g. application payloads) leave it unimplemented; SD-bearing types (e.g. RawPayload’s VecSdHeader payload) override.

Source

fn for_each_service_instance<F>(&self, _f: F)
where F: FnMut(u16, u16),

Visit (service_id, instance_id) for every SD entry in this payload, regardless of entry type, with f.

Used by the Client run loop for per-service-instance session/reboot tracking so that all SD traffic (not just offers) contributes to reboot detection.

Visitor pattern for the same no_std reason as Self::for_each_offered_endpoint; default visits nothing.

Source

fn offered_endpoints(&self) -> Vec<OfferedEndpoint>

Convenience accessor returning all offered endpoints as a heap Vec. Wraps Self::for_each_offered_endpoint so std users get the original ergonomic shape; bare-metal users use the visitor directly. Gated on feature = "std".

Source

fn service_instances(&self) -> Vec<(u16, u16)>

Convenience accessor returning all (service_id, instance_id) pairs as a heap Vec. Wraps Self::for_each_service_instance for std users. Gated on feature = "std".

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§