Skip to main content

FileHeader

Struct FileHeader 

Source
pub struct FileHeader {
    pub magic: [u8; 4],
    pub version: u16,
    pub flags: u16,
    pub data_length: u64,
    pub crc32: u32,
    pub blake3_hash: [u8; 32],
}
Expand description

File header for .acomm format.

Supports both v2 (CRC32, 20-byte header) and v3 (Blake3, 48-byte header).

Fields§

§magic: [u8; 4]§version: u16§flags: u16§data_length: u64§crc32: u32

CRC32 checksum (used in v2 only).

§blake3_hash: [u8; 32]

Blake3 hash (used in v3+).

Implementations§

Source§

impl FileHeader

Source

pub const SIZE_V3: usize

Header size for v3 (Blake3): magic(4) + version(2) + flags(2) + data_length(8) + blake3(32) = 48.

Source

pub const SIZE_V2: usize

Header size for v2 (CRC32): magic(4) + version(2) + flags(2) + data_length(8) + crc32(4) = 20.

Source

pub const SIZE: usize = Self::SIZE_V3

Default header size (current version = v3).

Source

pub fn new(data: &[u8]) -> Self

Create a new v3 header (Blake3) for the given data.

Source

pub fn new_with_flags(data: &[u8], flags: u16) -> Self

Create a new v3 header (Blake3) with explicit flags.

Source

pub fn new_legacy(data: &[u8]) -> Self

Create a legacy v2 header (CRC32) for the given data.

Source

pub fn to_bytes(&self) -> Vec<u8>

Serialize header to bytes.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<Self, String>

Parse header from bytes, auto-detecting version for correct layout.

Source

pub fn header_size(&self) -> usize

Return the header size for this version.

Source

pub fn verify(&self, data: &[u8]) -> bool

Verify integrity of data against the stored hash/checksum.

Source

pub fn verify_crc(&self, data: &[u8]) -> bool

Verify CRC32 of data matches header (v2 legacy).

Source

pub fn verify_blake3(&self, data: &[u8]) -> bool

Verify Blake3 hash of data matches header (v3+).

Source

pub fn is_zstd(&self) -> bool

Returns true if the payload is Zstd-compressed (FLAG_ZSTD set).

Trait Implementations§

Source§

impl Clone for FileHeader

Source§

fn clone(&self) -> FileHeader

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 FileHeader

Source§

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

Formats the value using the given formatter. Read more

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V