[][src]Struct framed::typed::Codec

pub struct Codec<T: DeserializeOwned + Serialize> { /* fields omitted */ }

Contains methods for encoding and decoding a serializable type T with a specific configuration.

Construct an instance from a Config instance with the Config::to_codec method.

Methods

impl<T: DeserializeOwned + Serialize> Codec<T>[src]

pub fn encode_to_slice(
    &mut self,
    v: &T,
    ser_buf: &mut TempBuffer,
    dest: &mut Encoded
) -> Result<usize>
[src]

Serializes and encodes the supplied value v into destination buffer dest, using ser_buf as a temporary serialization buffer. Available from no_std crates.

Returns the number of bytes written to the beginning of dest.

Panics

This will panic if the supplied buffers are too small to serialize a value of T. Callers must ensure that:

  • ser_buf.len() >= max_serialize_buf_len::<T>() and
  • dest.len() >= max_encoded_len::<T>().

Examples

See the no_std usage example in the typed module documentation.

pub fn decode_from_slice(
    &mut self,
    e: &Encoded,
    de_buf: &mut TempBuffer
) -> Result<T>
[src]

Decodes the supplied encoded frame e, then deserializes its payload as a value of type T, using de_buf as a temporary deserialization buffer. Available from no_std crates.

Returns the deserialized value.

Panics

This will panic if the supplied buffer is too small to deserialize a value of T. Callers must ensure that:

  • de_buf.len() >= max_serialize_buf_len::<T>().

Examples

See the no_std usage example in the typed module documentation.

Auto Trait Implementations

impl<T> Send for Codec<T> where
    T: Send

impl<T> Sync for Codec<T> where
    T: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.