pub trait MctpMedium: Sized {
type Frame: MctpMediumFrame<Self>;
type Error: Debug + Copy + Clone + PartialEq + Eq;
type ReplyContext: Debug + Copy + Clone + PartialEq + Eq;
type Encoding: BufferEncoding;
// Required methods
fn max_message_body_size(&self) -> usize;
fn deserialize<'buf>(
&self,
packet: &'buf [u8],
) -> MctpPacketResult<(Self::Frame, EncodingDecoder<'buf, Self::Encoding>), Self>;
fn serialize<'buf, F>(
&self,
reply_context: Self::ReplyContext,
buffer: &'buf mut [u8],
message_writer: F,
) -> MctpPacketResult<&'buf [u8], Self>
where F: for<'a> FnOnce(&mut EncodingEncoder<'a, Self::Encoding>) -> MctpPacketResult<(), Self>;
}Required Associated Types§
Sourcetype Frame: MctpMediumFrame<Self>
type Frame: MctpMediumFrame<Self>
the medium specific header and trailer for the packet
Sourcetype Error: Debug + Copy + Clone + PartialEq + Eq
type Error: Debug + Copy + Clone + PartialEq + Eq
the error type for deserialization of the medium specific header
type ReplyContext: Debug + Copy + Clone + PartialEq + Eq
Sourcetype Encoding: BufferEncoding
type Encoding: BufferEncoding
the byte-stuffing transform used by this medium when (de)serializing
wire bytes. Stateless — see [crate::buffer_encoding]. Most media
use PassthroughEncoding
(no transform); media that need byte-stuffing (e.g., DSP0253 serial)
supply their own impl.
Required Methods§
Sourcefn max_message_body_size(&self) -> usize
fn max_message_body_size(&self) -> usize
the maximum transmission unit for the medium
Sourcefn deserialize<'buf>(
&self,
packet: &'buf [u8],
) -> MctpPacketResult<(Self::Frame, EncodingDecoder<'buf, Self::Encoding>), Self>
fn deserialize<'buf>( &self, packet: &'buf [u8], ) -> MctpPacketResult<(Self::Frame, EncodingDecoder<'buf, Self::Encoding>), Self>
Deserialize a packet into the medium-specific header (frame) and an
EncodingDecoder that wraps the inner stuffed-region bytes.
Higher layers (e.g., parse_transport_header, the payload copy
loop in MctpPacketContext) read decoded bytes through the
returned decoder and physically cannot bypass the medium’s
encoding by slicing the underlying buffer directly.
Sourcefn serialize<'buf, F>(
&self,
reply_context: Self::ReplyContext,
buffer: &'buf mut [u8],
message_writer: F,
) -> MctpPacketResult<&'buf [u8], Self>
fn serialize<'buf, F>( &self, reply_context: Self::ReplyContext, buffer: &'buf mut [u8], message_writer: F, ) -> MctpPacketResult<&'buf [u8], Self>
Serialize a packet by allowing the caller’s message_writer
closure to write decoded bytes into the medium’s stuffed region
through an EncodingEncoder. The medium owns its outer framing
(e.g., SMBus header + PEC, DSP0253 start/end flags + FCS) and
inspects the encoder’s
wire_position after the
closure returns to size headers/trailers and compute checksums.
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.