pub trait Element: Sized {
    type Config: for<'a> From<&'a Config>;

Show 13 methods fn zeroed() -> Self; fn len(config: &Self::Config) -> usize; fn to_buffer(
        &self,
        config: &Self::Config,
        context: &mut ContextUnit,
        buf: &mut [u8]
    ); fn try_from_buffer_in_place<S>(
        &mut self,
        config: &Self::Config,
        context: &mut Context<S>,
        buf: &[u8]
    ) -> Result<()>
    where
        S: Read + Seek
; fn validate(&self, preamble: &Preamble) -> Result<()>; fn validate_buffer_len(config: &Self::Config, len: usize) -> Result<()> { ... } fn to_vec(&self, config: &Self::Config, context: &mut ContextUnit) -> Vec<u8> { ... } fn try_from_buffer<S>(
        config: &Self::Config,
        context: &mut Context<S>,
        buf: &[u8]
    ) -> Result<Self>
    where
        S: Read + Seek
, { ... } fn try_decode_in_place<'a, S>(
        &mut self,
        config: &Self::Config,
        context: &mut Context<S>,
        buf: &'a [u8]
    ) -> Result<&'a [u8]>
    where
        S: Read + Seek
, { ... } fn try_decode<'a, S>(
        config: &Self::Config,
        context: &mut Context<S>,
        buf: &'a [u8]
    ) -> Result<(Self, &'a [u8])>
    where
        S: Read + Seek
, { ... } fn encode<'a>(
        &self,
        config: &Self::Config,
        context: &mut ContextUnit,
        buf: &'a mut [u8]
    ) -> &'a mut [u8]Notable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8] { ... } fn try_to_writer<W>(
        &self,
        writer: W,
        config: &Self::Config,
        context: &mut ContextUnit
    ) -> Result<usize>
    where
        W: Write
, { ... } fn try_from_context<S>(
        config: &Self::Config,
        context: &mut Context<S>
    ) -> Result<Self>
    where
        S: Read + Seek
, { ... }
}
Expand description

Describe a CDF element

Required Associated Types

Configuration for the serialization and deserialization

Required Methods

A zeroed/default instance of the type.

Serializable length

Every element is a function of the config so seek/lookups will be constant-time.

The serialized type must not contain more bytes than specified here. However, it might, optionally, use less bytes. Regardless, it will consume this defined amount of bytes during serialization.

Write the type into the buffer.

Panics

The buffer must, provided a correct definition of Element::len, contain enough bytes to fully serialize the type. This can be checkedvia Element::validate_buffer_len.

Deserialize the type from a given buffer

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

Perform the internal validations of the associated element

Provided Methods

Assert the buffer is big enough to store the type

Serialize the object into a bytes array.

Create a new instance of the type from the provided buffer

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

Assume its inside a validate buffer context

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

Assume its inside a validate buffer context

Read an element into the buffer, returning the remainder bytes

Assume its inside a validate buffer context

Send the bytes representation of an element to a writer

Fetch a new element from a context

Implementations on Foreign Types

Implementors