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

Trait ReadDecodePayload

Source
pub trait ReadDecodePayload<T>: PayloadCodec {
    // Required method
    fn decode_payload_from_reader<R: Read>(
        reader: R,
        payload_len: usize,
    ) -> Result<T, UWireError>;
}
Expand description

Decodes a typed value from an ordered payload byte stream.

Required Methods§

Source

fn decode_payload_from_reader<R: Read>( reader: R, payload_len: usize, ) -> Result<T, UWireError>

Decodes T from reader, which must yield exactly payload_len bytes.

Implementations must treat payload_len as a finite allocation and read bound before reserving payload-sized storage. They must consume exactly that many bytes, distinguish an early EOF from malformed payload data, and check for an additional byte so overlong input is rejected. Reader errors and malformed input must return UWireError, not panic. A codec may enforce a lower implementation-specific maximum, but must report that limit rather than allocating first and rejecting later.

§Errors

Returns an error if the reader fails, yields an unexpected byte count, or contains malformed payload bytes for this codec.

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§