Skip to main content

ObjectHeader

Struct ObjectHeader 

Source
pub struct ObjectHeader {
    pub flags: u8,
    pub messages: Vec<ObjectHeaderMessage>,
}
Expand description

Object Header v2.

Fields§

§flags: u8

Header flags byte. Bits 0-1 control chunk0 size encoding. Other bits control optional fields (timestamps, attr thresholds, creation order).

§messages: Vec<ObjectHeaderMessage>

The ordered list of header messages.

Implementations§

Source§

impl ObjectHeader

Source

pub fn new() -> Self

Create a new, empty object header with default flags.

Defaults: bits 0-1 = 2 (4-byte chunk size encoding), no timestamps, no attribute creation order, no non-default thresholds.

Source

pub fn add_message(&mut self, msg_type: u8, flags: u8, data: Vec<u8>)

Append a message to the object header.

Source

pub fn encode(&self) -> Vec<u8> ⓘ

Encode the object header to a byte vector, including “OHDR” signature and trailing checksum.

Source

pub fn decode(buf: &[u8]) -> FormatResult<(Self, usize)>

Decode an object header from a byte buffer. Returns the parsed header and the number of bytes consumed from the buffer.

Source§

impl ObjectHeader

Source

pub fn decode_v1(buf: &[u8]) -> FormatResult<(Self, usize)>

Decode a v1 object header from a byte buffer.

v1 headers do NOT have the “OHDR” signature or a checksum. The layout is:

Byte 0: version = 1
Byte 1: reserved
Bytes 2-3: num_messages (u16 LE)
Bytes 4-7: obj_ref_count (u32 LE)
Bytes 8-11: header_data_size (u32 LE) — size of message data in first chunk
Messages follow, each:
  type: u16 LE
  data_size: u16 LE
  flags: u8
  reserved: 3 bytes
  data: data_size bytes (padded to 8-byte alignment)
Source

pub fn decode_any(buf: &[u8]) -> FormatResult<(Self, usize)>

Auto-detect and decode either v1 or v2 object header.

Checks for the “OHDR” signature to decide v2; otherwise tries v1.

Trait Implementations§

Source§

impl Clone for ObjectHeader

Source§

fn clone(&self) -> ObjectHeader

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ObjectHeader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ObjectHeader

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for ObjectHeader

Source§

impl PartialEq for ObjectHeader

Source§

fn eq(&self, other: &ObjectHeader) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ObjectHeader

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.