Preview of the proposed up-rust native-frame-model branch (up-rust b6b99c6d, up-spec f0e9b17) — not released documentation. branch · write-up

Trait UFrameView

Source
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§

Source

type PayloadReader<'a>: Read + 'a where Self: 'a

Reader over the payload bytes in order.

Source

type PayloadSlices<'a>: Iterator<Item = &'a [u8]> + 'a where Self: 'a

Iterator over the payload’s storage segments in order.

Required Methods§

Source

fn metadata(&self) -> &UFrameMetadata

Returns the native frame metadata.

Source

fn payload_len(&self) -> usize

Returns the number of application payload bytes visible through this view.

Source

fn payload_reader(&self) -> Self::PayloadReader<'_>

Returns an ordered reader over the application payload bytes.

Source

fn payload_slices(&self) -> Self::PayloadSlices<'_>

Returns ordered borrowed payload slices.

Provided Methods§

Source

fn has_payload(&self) -> bool

Returns whether this view carries a payload, including a present empty payload.

Source

fn try_contiguous_payload(&self) -> Option<&[u8]>

Returns a contiguous borrowed payload view when this view can provide one without copying.

Source

fn decode_payload_from_reader_as<C, T>(&self) -> Result<T, UWireError>

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.

Implementors§

Source§

impl UFrameView for UOwnedFrame

Source§

type PayloadReader<'a> = Cursor<&'a [u8]> where Self: 'a

Source§

type PayloadSlices<'a> = IntoIter<&'a [u8]> where Self: 'a

Source§

impl UFrameView for UVecRxLease

Source§

type PayloadReader<'a> = Cursor<&'a [u8]> where Self: 'a

Source§

type PayloadSlices<'a> = IntoIter<&'a [u8]> where Self: 'a

Source§

impl<Rx, W, C> UFrameView for UWireRx<Rx, W, C>

Source§

type PayloadReader<'a> = <Rx as UEncodedRxFrame>::PayloadReader<'a> where Self: 'a

Source§

type PayloadSlices<'a> = <Rx as UEncodedRxFrame>::PayloadSlices<'a> where Self: 'a