DecodableElement

Trait DecodableElement 

Source
pub trait DecodableElement: Sized + Element {
    // Required method
    fn try_from_buffer_in_place<'a, 'b>(
        &'a mut self,
        ctx: &DecoderContext<'a>,
        buf: &'b [u8],
    ) -> Result<()>;

    // Provided methods
    fn try_from_buffer<'b>(
        ctx: &DecoderContext<'_>,
        buf: &'b [u8],
    ) -> Result<Self> { ... }
    fn try_decode_in_place<'a, 'b>(
        &mut self,
        ctx: &DecoderContext<'a>,
        buf: &'b [u8],
    ) -> Result<&'b [u8]> { ... }
    fn try_decode<'a, 'b>(
        ctx: &DecoderContext<'a>,
        buf: &'b [u8],
    ) -> Result<(Self, &'b [u8])> { ... }
    fn try_from_reader<R>(ctx: &DecoderContext<'_>, reader: R) -> Result<Self>
       where R: Read { ... }
}
Expand description

Element that can be decoded from a CDF file

Required Methods§

Source

fn try_from_buffer_in_place<'a, 'b>( &'a mut self, ctx: &DecoderContext<'a>, buf: &'b [u8], ) -> Result<()>

Deserialize the type from a given buffer

As in EncodableElement::to_buffer the implementor of this function can assume the buffer is big enough to contain all the required bytes.

Provided Methods§

Source

fn try_from_buffer<'b>(ctx: &DecoderContext<'_>, buf: &'b [u8]) -> Result<Self>

Create a new instance of the type from the provided buffer

Source

fn try_decode_in_place<'a, 'b>( &mut self, ctx: &DecoderContext<'a>, buf: &'b [u8], ) -> Result<&'b [u8]>

Write an element from the buffer, and return the remainder bytes

Assume its inside a validate buffer context

Source

fn try_decode<'a, 'b>( ctx: &DecoderContext<'a>, buf: &'b [u8], ) -> Result<(Self, &'b [u8])>

Write an element from the buffer, and return the remainder bytes

Assume its inside a validate buffer context

Source

fn try_from_reader<R>(ctx: &DecoderContext<'_>, reader: R) -> Result<Self>
where R: Read,

Fetch a new element from a context

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.

Implementations on Foreign Types§

Source§

impl DecodableElement for bool

Source§

fn try_from_buffer_in_place<'b>( &mut self, ctx: &DecoderContext<'_>, buf: &'b [u8], ) -> Result<()>

Source§

impl DecodableElement for u64

Source§

fn try_from_buffer_in_place<'b>( &mut self, ctx: &DecoderContext<'_>, buf: &'b [u8], ) -> Result<()>

Source§

impl DecodableElement for ()

Source§

fn try_from_buffer_in_place<'b>( &mut self, _ctx: &DecoderContext<'_>, _buf: &'b [u8], ) -> Result<()>

Source§

impl DecodableElement for usize

Source§

fn try_from_buffer_in_place<'b>( &mut self, ctx: &DecoderContext<'_>, buf: &'b [u8], ) -> Result<()>

Source§

impl<T> DecodableElement for Option<T>

Source§

fn try_from_buffer_in_place<'b>( &mut self, ctx: &DecoderContext<'_>, buf: &'b [u8], ) -> Result<()>

Source§

impl<T> DecodableElement for PhantomData<T>

Source§

fn try_from_buffer_in_place<'b>( &mut self, _ctx: &DecoderContext<'_>, _buf: &'b [u8], ) -> Result<()>

Implementors§