Trait rustdds::dds::adapters::no_key::DeserializerAdapter

source ·
pub trait DeserializerAdapter<D> {
    type Error: Error;
    type Decoded;

    // Required methods
    fn supported_encodings() -> &'static [RepresentationIdentifier];
    fn transform_decoded(decoded: Self::Decoded) -> D;

    // Provided methods
    fn from_bytes_with<S>(
        input_bytes: &[u8],
        encoding: RepresentationIdentifier,
        decoder: S
    ) -> Result<D, S::Error>
       where S: Decode<Self::Decoded> { ... }
    fn from_bytes(
        input_bytes: &[u8],
        encoding: RepresentationIdentifier
    ) -> Result<D, Self::Error>
       where Self: DefaultDecoder<D> { ... }
}
Expand description

trait for connecting a Deserializer implementation and DataReader together - no_key version.

Deserialization is done in two steps: decode and transform. The basic pipeline is:

byte slice → decode → value of type Self::Decoded → call Self::transform_decoded → value of type D

The transform step may be an identity function, which means that Self::Decoded and D are the same.

The decoding step can be parameterized at run time, if the decoder is defined suitaby. If there is no need for such parameterization (i.e. decoder object), use subtrait DefaultDecoder, which defines decoding that needs no decoder “seed” object at run time. In that case decoding is dependent only on the type of the decoder and incoming byte stream.

Required Associated Types§

source

type Error: Error

The error type returned when decoding fails.

source

type Decoded

Type after decoding.

The adapter might apply additional operations or wrapper types to the decoded value, so this type might be different from D.

Required Methods§

source

fn supported_encodings() -> &'static [RepresentationIdentifier]

Which data representations can the DeserializerAdapter read? See RTPS specification Section 10 and Table 10.3

source

fn transform_decoded(decoded: Self::Decoded) -> D

Transform the Self::Decoded type returned by the decoder into a value of type D.

If Self::Decoded is set to D, this method can be the identity function.

Provided Methods§

source

fn from_bytes_with<S>( input_bytes: &[u8], encoding: RepresentationIdentifier, decoder: S ) -> Result<D, S::Error>
where S: Decode<Self::Decoded>,

Deserialize data from bytes to an object using the given decoder.

encoding must be something given by supported_encodings(), or implementation may fail with Err or panic!().

source

fn from_bytes( input_bytes: &[u8], encoding: RepresentationIdentifier ) -> Result<D, Self::Error>
where Self: DefaultDecoder<D>,

Deserialize data from bytes to an object. encoding must be something given by supported_encodings(), or implementation may fail with Err or panic!().

Only usable if the adapter has a default decoder, i.e. implements DefaultDecoder.

Object Safety§

This trait is not object safe.

Implementors§