pub trait UFrameView {
type PayloadReader<'a>: Read + 'a
where Self: 'a;
type PayloadSlices<'a>: Iterator<Item = &'a [u8]> + 'a
where Self: 'a;
// Required methods
fn metadata(&self) -> &UFrameMetadata;
fn payload_len(&self) -> usize;
fn payload_reader(&self) -> Self::PayloadReader<'_>;
fn payload_slices(&self) -> Self::PayloadSlices<'_>;
// Provided methods
fn has_payload(&self) -> bool { ... }
fn try_contiguous_payload(&self) -> Option<&[u8]> { ... }
fn decode_payload_from_reader_as<C, T>(&self) -> Result<T, UWireError>
where C: PayloadCodec + ReadDecodePayload<T> { ... }
}Expand description
Role: the neutral read vocabulary every received frame speaks, whatever the family; implemented by frames and leases, consumed by decoding code — see the trait map.
Neutral view of frame metadata plus ordered payload bytes.
Required Associated Types§
Sourcetype PayloadReader<'a>: Read + 'a
where
Self: 'a
type PayloadReader<'a>: Read + 'a where Self: 'a
Reader over the payload bytes in order.
Sourcetype PayloadSlices<'a>: Iterator<Item = &'a [u8]> + 'a
where
Self: 'a
type PayloadSlices<'a>: Iterator<Item = &'a [u8]> + 'a where Self: 'a
Iterator over the payload’s storage segments in order.
Required Methods§
Sourcefn metadata(&self) -> &UFrameMetadata
fn metadata(&self) -> &UFrameMetadata
Returns the native frame metadata.
Sourcefn payload_len(&self) -> usize
fn payload_len(&self) -> usize
Returns the number of application payload bytes visible through this view.
Sourcefn payload_reader(&self) -> Self::PayloadReader<'_>
fn payload_reader(&self) -> Self::PayloadReader<'_>
Returns an ordered reader over the application payload bytes.
Sourcefn payload_slices(&self) -> Self::PayloadSlices<'_>
fn payload_slices(&self) -> Self::PayloadSlices<'_>
Returns ordered borrowed payload slices.
Provided Methods§
Sourcefn has_payload(&self) -> bool
fn has_payload(&self) -> bool
Returns whether this view carries a payload, including a present empty payload.
Sourcefn try_contiguous_payload(&self) -> Option<&[u8]>
fn try_contiguous_payload(&self) -> Option<&[u8]>
Returns a contiguous borrowed payload view when this view can provide one without copying.
Sourcefn decode_payload_from_reader_as<C, T>(&self) -> Result<T, UWireError>where
C: PayloadCodec + ReadDecodePayload<T>,
fn decode_payload_from_reader_as<C, T>(&self) -> Result<T, UWireError>where
C: PayloadCodec + ReadDecodePayload<T>,
Decodes this frame view from its ordered payload reader with codec C.
This path works for both contiguous and segmented receive storage without forcing a coalescing copy before the selected codec sees the bytes.
§Errors
Returns an error if the frame has no payload, has missing or incompatible encoding metadata, or if the codec cannot decode the payload 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.