Element

Trait Element 

Source
pub trait Element: Default {
    // Required methods
    fn len(ctx: &Config) -> usize;
    fn validate(&self, preamble: &Preamble) -> Result<()>;

    // Provided method
    fn validate_buffer(config: &Config, buffer: &[u8]) -> Result<()> { ... }
}
Expand description

Describe a CDF element

Required Methods§

Source

fn len(ctx: &Config) -> usize

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.

Source

fn validate(&self, preamble: &Preamble) -> Result<()>

Perform the internal validations of the associated element

Provided Methods§

Source

fn validate_buffer(config: &Config, buffer: &[u8]) -> Result<()>

Assert the buffer is big enough to store the type

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 Element for bool

Source§

fn len(_ctx: &Config) -> usize

Source§

fn validate(&self, _preamble: &Preamble) -> Result<()>

Source§

impl Element for u64

Source§

fn len(_ctx: &Config) -> usize

Source§

fn validate(&self, _preamble: &Preamble) -> Result<()>

Source§

impl Element for ()

Source§

fn len(_ctx: &Config) -> usize

Source§

fn validate(&self, _preamble: &Preamble) -> Result<()>

Source§

impl Element for usize

Source§

fn len(ctx: &Config) -> usize

Source§

fn validate(&self, _preamble: &Preamble) -> Result<()>

Source§

impl<T> Element for Option<T>
where T: Element,

Source§

fn len(ctx: &Config) -> usize

Source§

fn validate(&self, preamble: &Preamble) -> Result<()>

Source§

impl<T> Element for PhantomData<T>

Source§

fn len(_ctx: &Config) -> usize

Source§

fn validate(&self, _preamble: &Preamble) -> Result<()>

Implementors§