pub struct ObjectHeader {
pub flags: u8,
pub messages: Vec<ObjectHeaderMessage>,
}Expand description
Object Header v2.
Fields§
§flags: u8Header 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
impl ObjectHeader
Sourcepub fn new() -> Self
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.
Sourcepub fn add_message(&mut self, msg_type: u8, flags: u8, data: Vec<u8>)
pub fn add_message(&mut self, msg_type: u8, flags: u8, data: Vec<u8>)
Append a message to the object header.
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
Encode the object header to a byte vector, including “OHDR” signature and trailing checksum.
Sourcepub fn decode(buf: &[u8]) -> FormatResult<(Self, usize)>
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
impl ObjectHeader
Sourcepub fn decode_v1(buf: &[u8]) -> FormatResult<(Self, usize)>
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)Sourcepub fn decode_any(buf: &[u8]) -> FormatResult<(Self, usize)>
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
impl Clone for ObjectHeader
Source§fn clone(&self) -> ObjectHeader
fn clone(&self) -> ObjectHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more