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§
Required Methods§
Sourcefn message_id(&self) -> MessageId
fn message_id(&self) -> MessageId
Get the Message ID for the payload
Sourcefn as_sd_header(&self) -> Option<&Self::SdHeader>
fn as_sd_header(&self) -> Option<&Self::SdHeader>
Get the payload as a service discovery header
Sourcefn from_payload_bytes(
message_id: MessageId,
payload: &[u8],
) -> Result<Self, Error>
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
Sourcefn new_sd_payload(header: &Self::SdHeader) -> Self
fn new_sd_payload(header: &Self::SdHeader) -> Self
Create a PayloadWireFormat from a service discovery Header
Sourcefn sd_flags(&self) -> Option<Flags>
fn sd_flags(&self) -> Option<Flags>
Return the SD flags if this payload is a service discovery message.
Sourcefn required_size(&self) -> usize
fn required_size(&self) -> usize
Number of bytes required to write the payload
Sourcefn 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
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§
Sourcefn set_reboot_flag(_header: &mut Self::SdHeader, _reboot: RebootFlag)
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.
Sourcefn for_each_offered_endpoint<F>(&self, _f: F)where
F: FnMut(OfferedEndpoint),
fn for_each_offered_endpoint<F>(&self, _f: F)where
F: FnMut(OfferedEndpoint),
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.
Sourcefn for_each_service_instance<F>(&self, _f: F)
fn for_each_service_instance<F>(&self, _f: F)
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.
Sourcefn offered_endpoints(&self) -> Vec<OfferedEndpoint>
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".
Sourcefn service_instances(&self) -> Vec<(u16, u16)>
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".