pub trait Deserialize: DataType {
    // Required method
    fn deserialize(
        cursor: &mut ReadCursor<'_>
    ) -> Result<Self, DeserializeError>
       where Self: Sized;

    // Provided methods
    fn deserialize_zero_copy(cursor: &mut ReadCursor<'_>) -> Self
       where Self: Sized + AsBytes + FromBytes { ... }
    fn deserialize_from_bytes(bytes: &[u8]) -> Result<Self, DeserializeError>
       where Self: Sized { ... }
}
Expand description

Trait for types that can be deserialized from Cyphal transfers

Required Methods§

source

fn deserialize(cursor: &mut ReadCursor<'_>) -> Result<Self, DeserializeError>where Self: Sized,

Deserializes a value and returns it

Provided Methods§

source

fn deserialize_zero_copy(cursor: &mut ReadCursor<'_>) -> Selfwhere Self: Sized + AsBytes + FromBytes,

Deserializes a value from a slice of bytes and returns it

This is available only for types that implement Sized, AsBytes, and FromBytes.

Panics

This function panics if the provided cursor is not aligned to a byte boundary.

source

fn deserialize_from_bytes(bytes: &[u8]) -> Result<Self, DeserializeError>where Self: Sized,

A convenience function that creates a cursor around the provided bytes and calls deserialize

Implementors§