[][src]Trait declio::Decode

pub trait Decode<Ctx = ()>: Sized {
    fn decode<R>(ctx: Ctx, reader: &mut R) -> Result<Self, Error>
    where
        R: Read
; }

A type that can be decoded from a byte stream.

Required methods

fn decode<R>(ctx: Ctx, reader: &mut R) -> Result<Self, Error> where
    R: Read

Decodes a value from the given reader.

Loading content...

Implementations on Foreign Types

impl<T, Ctx> Decode<(Len, Ctx)> for Vec<T> where
    T: Decode<Ctx>,
    Ctx: Clone
[src]

fn decode<R>(
    (Len, inner_ctx): (Len, Ctx),
    reader: &mut R
) -> Result<Self, Error> where
    R: Read
[src]

Decodes multiple values of type T, collecting them in a Vec.

The length of the vector / number of elements decoded is equal to the value of the Len context.

impl<T> Decode<Len> for Vec<T> where
    T: Decode
[src]

fn decode<R>(len: Len, reader: &mut R) -> Result<Self, Error> where
    R: Read
[src]

Decodes multiple values of type T, collecting them in a Vec.

The length of the vector / number of elements decoded is equal to the value of the Len context.

impl<T, Ctx> Decode<Ctx> for Option<T> where
    T: Decode<Ctx>, 
[src]

fn decode<R>(inner_ctx: Ctx, reader: &mut R) -> Result<Self, Error> where
    R: Read
[src]

Decodes a value of type T and wraps it in Some.

Detecting and deserializing a None should be done outside of this function by checking the relevant conditions in other decoded values and skipping this call if a None is expected.

Since serializing a None writes nothing, deserialization is also a no-op; just construct a value of None.

impl<'a, T: ?Sized, Ctx> Decode<Ctx> for Cow<'a, T> where
    T: ToOwned,
    T::Owned: Decode<Ctx>, 
[src]

fn decode<R>(inner_ctx: Ctx, reader: &mut R) -> Result<Self, Error> where
    R: Read
[src]

Decodes a value of type T::Owned.

impl<T, Ctx> Decode<Ctx> for Box<T> where
    T: Decode<Ctx>, 
[src]

fn decode<R>(inner_ctx: Ctx, reader: &mut R) -> Result<Self, Error> where
    R: Read
[src]

Decodes a value of type T and boxes it.

impl Decode<()> for ()[src]

fn decode<R>(_: (), _: &mut R) -> Result<Self, Error> where
    R: Read
[src]

No-op.

impl Decode<()> for bool[src]

fn decode<R>(_: (), reader: &mut R) -> Result<Self, Error> where
    R: Read
[src]

Decodes a 1-byte as true, a 0-byte as false, and any other byte value as an error.

impl Decode<Endian> for u8[src]

impl Decode<()> for u8[src]

impl Decode<Endian> for u16[src]

impl Decode<()> for u16[src]

impl Decode<Endian> for u32[src]

impl Decode<()> for u32[src]

impl Decode<Endian> for u64[src]

impl Decode<()> for u64[src]

impl Decode<Endian> for u128[src]

impl Decode<()> for u128[src]

impl Decode<Endian> for i8[src]

impl Decode<()> for i8[src]

impl Decode<Endian> for i16[src]

impl Decode<()> for i16[src]

impl Decode<Endian> for i32[src]

impl Decode<()> for i32[src]

impl Decode<Endian> for i64[src]

impl Decode<()> for i64[src]

impl Decode<Endian> for i128[src]

impl Decode<()> for i128[src]

impl Decode<Endian> for f32[src]

impl Decode<()> for f32[src]

impl Decode<Endian> for f64[src]

impl Decode<()> for f64[src]

Loading content...

Implementors

Loading content...