Skip to main content

FileHeader

Struct FileHeader 

Source
#[repr(C)]
pub struct FileHeader {
Show 20 fields pub magic: [u8; 4], pub version: u16, pub flags: u16, pub file_id: u64, pub current_version: u64, pub root_hash: [u8; 32], pub current_hash: [u8; 32], pub created_at: u64, pub modified_at: u64, pub encrypted_rules_offset: u64, pub encrypted_rules_length: u64, pub version_chain_offset: u64, pub version_chain_count: u64, pub signatures_offset: u64, pub signatures_count: u64, pub audit_trail_offset: u64, pub audit_trail_count: u64, pub string_table_offset: u64, pub string_table_length: u64, pub reserved: [u8; 72],
}
Expand description

File header structure (256 bytes, RFC-0002 Section 3.1)

This struct uses zerocopy for zero-copy parsing from byte slices. All integers are little-endian.

§Examples

use aion_context::parser::FileHeader;
use zerocopy::FromBytes;

let data = vec![0u8; 256];
let header = FileHeader::read_from_prefix(&data)?;

Fields§

§magic: [u8; 4]

Magic number: “AION” (0x41494F4E)

§version: u16

Format version (current = 2)

§flags: u16

Feature flags

  • Bit 0: Encrypted (1 = encrypted, 0 = plaintext)
  • Bit 1-15: Reserved (must be 0)
§file_id: u64

Unique file identifier

§current_version: u64

Current version number (monotonically increasing)

§root_hash: [u8; 32]

Root hash (BLAKE3, genesis version)

§current_hash: [u8; 32]

Current hash (BLAKE3, latest version)

§created_at: u64

Creation timestamp (nanoseconds since Unix epoch)

§modified_at: u64

Last modification timestamp

§encrypted_rules_offset: u64

Encrypted rules section offset

§encrypted_rules_length: u64

Encrypted rules section length (bytes)

§version_chain_offset: u64

Version chain section offset

§version_chain_count: u64

Version chain count (number of entries)

§signatures_offset: u64

Signatures section offset

§signatures_count: u64

Signatures count

§audit_trail_offset: u64

Audit trail section offset

§audit_trail_count: u64

Audit trail count

§string_table_offset: u64

String table offset

§string_table_length: u64

String table length

§reserved: [u8; 72]

Reserved bytes (must be zero)

Implementations§

Source§

impl FileHeader

Source

pub const fn is_valid_magic(&self) -> bool

Validate header magic number

§Examples
use aion_context::parser::FileHeader;

let mut header = FileHeader::default();
assert!(header.is_valid_magic());

header.magic = *b"XXXX";
assert!(!header.is_valid_magic());

header.magic = *b"AION";
assert!(header.is_valid_magic());
Source

pub const fn is_encrypted(&self) -> bool

Check if file is encrypted

§Examples
use aion_context::parser::FileHeader;

let mut header = FileHeader::default();
assert!(!header.is_encrypted());

header.flags = 0x0001; // Set encrypted bit
assert!(header.is_encrypted());
Source

pub const fn file_id(&self) -> FileId

Get file ID as FileId type

§Examples
use aion_context::parser::FileHeader;
use aion_context::types::FileId;

let mut header = FileHeader::default();
header.file_id = 42;
assert_eq!(header.file_id(), FileId(42));
Source

pub const fn current_version(&self) -> VersionNumber

Get current version as VersionNumber type

Source

pub fn validate(&self) -> Result<()>

Validate header structure

Checks:

  • Magic number is correct
  • Version is supported
  • Reserved bytes are zero
§Errors

Returns error if validation fails

Trait Implementations§

Source§

impl AsBytes for FileHeader
where [u8; 4]: AsBytes, u16: AsBytes, u64: AsBytes, [u8; 32]: AsBytes, [u8; 72]: AsBytes, HasPadding<FileHeader, { _ }>: ShouldBe<false>,

Source§

fn as_bytes(&self) -> &[u8]

Gets the bytes of this value. Read more
Source§

fn as_bytes_mut(&mut self) -> &mut [u8]
where Self: FromBytes,

Gets the bytes of this value mutably. Read more
Source§

fn write_to(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to bytes. Read more
Source§

fn write_to_prefix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the prefix of bytes. Read more
Source§

fn write_to_suffix(&self, bytes: &mut [u8]) -> Option<()>

Writes a copy of self to the suffix of bytes. Read more
Source§

impl Clone for FileHeader

Source§

fn clone(&self) -> FileHeader

Returns a duplicate of the value. Read more
1.0.0 · 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
Source§

impl Default for FileHeader

Source§

fn default() -> Self

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

impl FromBytes for FileHeader

Source§

fn ref_from(bytes: &[u8]) -> Option<&Self>
where Self: Sized,

Interprets the given bytes as a &Self without copying. Read more
Source§

fn ref_from_prefix(bytes: &[u8]) -> Option<&Self>
where Self: Sized,

Interprets the prefix of the given bytes as a &Self without copying. Read more
Source§

fn ref_from_suffix(bytes: &[u8]) -> Option<&Self>
where Self: Sized,

Interprets the suffix of the given bytes as a &Self without copying. Read more
Source§

fn mut_from(bytes: &mut [u8]) -> Option<&mut Self>
where Self: Sized + AsBytes,

Interprets the given bytes as a &mut Self without copying. Read more
Source§

fn mut_from_prefix(bytes: &mut [u8]) -> Option<&mut Self>
where Self: Sized + AsBytes,

Interprets the prefix of the given bytes as a &mut Self without copying. Read more
Source§

fn mut_from_suffix(bytes: &mut [u8]) -> Option<&mut Self>
where Self: Sized + AsBytes,

Interprets the suffix of the given bytes as a &mut Self without copying. Read more
Source§

fn slice_from(bytes: &[u8]) -> Option<&[Self]>
where Self: Sized,

Interprets the given bytes as a &[Self] without copying. Read more
Source§

fn slice_from_prefix(bytes: &[u8], count: usize) -> Option<(&[Self], &[u8])>
where Self: Sized,

Interprets the prefix of the given bytes as a &[Self] with length equal to count without copying. Read more
Source§

fn slice_from_suffix(bytes: &[u8], count: usize) -> Option<(&[u8], &[Self])>
where Self: Sized,

Interprets the suffix of the given bytes as a &[Self] with length equal to count without copying. Read more
Source§

fn mut_slice_from(bytes: &mut [u8]) -> Option<&mut [Self]>
where Self: Sized + AsBytes,

Interprets the given bytes as a &mut [Self] without copying. Read more
Source§

fn mut_slice_from_prefix( bytes: &mut [u8], count: usize, ) -> Option<(&mut [Self], &mut [u8])>
where Self: Sized + AsBytes,

Interprets the prefix of the given bytes as a &mut [Self] with length equal to count without copying. Read more
Source§

fn mut_slice_from_suffix( bytes: &mut [u8], count: usize, ) -> Option<(&mut [u8], &mut [Self])>
where Self: Sized + AsBytes,

Interprets the suffix of the given bytes as a &mut [Self] with length equal to count without copying. Read more
Source§

fn read_from(bytes: &[u8]) -> Option<Self>
where Self: Sized,

Reads a copy of Self from bytes. Read more
Source§

fn read_from_prefix(bytes: &[u8]) -> Option<Self>
where Self: Sized,

Reads a copy of Self from the prefix of bytes. Read more
Source§

fn read_from_suffix(bytes: &[u8]) -> Option<Self>
where Self: Sized,

Reads a copy of Self from the suffix of bytes. Read more
Source§

impl FromZeroes for FileHeader

Source§

fn zero(&mut self)

Overwrites self with zeroes. Read more
Source§

fn new_zeroed() -> Self
where Self: Sized,

Creates an instance of Self from zeroed bytes. Read more
Source§

impl Copy for FileHeader

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

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = 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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more