Trait Header

Source
pub trait Header:
    Clone
    + Sized
    + PartialEq
    + Eq
    + Debug {
    // Required methods
    fn payload_len(&self) -> usize;
    fn set_size(&mut self, total_size: usize);

    // Provided method
    fn total_size(&self) -> usize { ... }
}
Expand description

A sized header type for DynSizedStructure.

Note that header refers to the header pattern. Thus, depending on the use case, this is not just a tag header. Instead, it refers to all bytes that are fixed and not part of any optional terminating dynamic [u8] slice in a DynSizedStructure.

The alignment of implementors must be the compatible with the demands for the corresponding structure, which typically is ALIGNMENT.

Required Methods§

Source

fn payload_len(&self) -> usize

Returns the length of the payload, i.e., the bytes that are additional to the header. The value is measured in bytes.

Source

fn set_size(&mut self, total_size: usize)

Updates the header with the given total_size.

Provided Methods§

Source

fn total_size(&self) -> usize

Returns the total size of the struct, thus the size of the header itself plus Header::payload_len.

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.

Implementors§