#[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: u16Format version (current = 2)
flags: u16Feature flags
- Bit 0: Encrypted (1 = encrypted, 0 = plaintext)
- Bit 1-15: Reserved (must be 0)
file_id: u64Unique file identifier
current_version: u64Current version number (monotonically increasing)
root_hash: [u8; 32]Root hash (BLAKE3, genesis version)
current_hash: [u8; 32]Current hash (BLAKE3, latest version)
created_at: u64Creation timestamp (nanoseconds since Unix epoch)
modified_at: u64Last modification timestamp
encrypted_rules_offset: u64Encrypted rules section offset
encrypted_rules_length: u64Encrypted rules section length (bytes)
version_chain_offset: u64Version chain section offset
version_chain_count: u64Version chain count (number of entries)
signatures_offset: u64Signatures section offset
signatures_count: u64Signatures count
audit_trail_offset: u64Audit trail section offset
audit_trail_count: u64Audit trail count
string_table_offset: u64String table offset
string_table_length: u64String table length
reserved: [u8; 72]Reserved bytes (must be zero)
Implementations§
Source§impl FileHeader
impl FileHeader
Sourcepub const fn is_valid_magic(&self) -> bool
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());Sourcepub const fn is_encrypted(&self) -> bool
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());Sourcepub const fn file_id(&self) -> FileId
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));Sourcepub const fn current_version(&self) -> VersionNumber
pub const fn current_version(&self) -> VersionNumber
Get current version as VersionNumber type
Trait Implementations§
Source§impl AsBytes for FileHeader
impl AsBytes for FileHeader
Source§impl Clone for FileHeader
impl Clone for FileHeader
Source§fn clone(&self) -> FileHeader
fn clone(&self) -> FileHeader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FileHeader
impl Debug for FileHeader
Source§impl Default for FileHeader
impl Default for FileHeader
Source§impl FromBytes for FileHeader
impl FromBytes for FileHeader
Source§fn mut_from_prefix(bytes: &mut [u8]) -> Option<&mut Self>
fn mut_from_prefix(bytes: &mut [u8]) -> Option<&mut Self>
Source§fn mut_from_suffix(bytes: &mut [u8]) -> Option<&mut Self>
fn mut_from_suffix(bytes: &mut [u8]) -> Option<&mut Self>
Source§fn slice_from_prefix(bytes: &[u8], count: usize) -> Option<(&[Self], &[u8])>where
Self: Sized,
fn slice_from_prefix(bytes: &[u8], count: usize) -> Option<(&[Self], &[u8])>where
Self: Sized,
bytes as a &[Self] with length
equal to count without copying. Read moreSource§fn slice_from_suffix(bytes: &[u8], count: usize) -> Option<(&[u8], &[Self])>where
Self: Sized,
fn slice_from_suffix(bytes: &[u8], count: usize) -> Option<(&[u8], &[Self])>where
Self: Sized,
bytes as a &[Self] with length
equal to count without copying. Read moreSource§fn mut_slice_from(bytes: &mut [u8]) -> Option<&mut [Self]>
fn mut_slice_from(bytes: &mut [u8]) -> Option<&mut [Self]>
Source§fn mut_slice_from_prefix(
bytes: &mut [u8],
count: usize,
) -> Option<(&mut [Self], &mut [u8])>
fn mut_slice_from_prefix( bytes: &mut [u8], count: usize, ) -> Option<(&mut [Self], &mut [u8])>
bytes as a &mut [Self] with length
equal to count without copying. Read moreSource§fn mut_slice_from_suffix(
bytes: &mut [u8],
count: usize,
) -> Option<(&mut [u8], &mut [Self])>
fn mut_slice_from_suffix( bytes: &mut [u8], count: usize, ) -> Option<(&mut [u8], &mut [Self])>
bytes as a &mut [Self] with length
equal to count without copying. Read moreSource§impl FromZeroes for FileHeaderwhere
[u8; 4]: FromZeroes,
u16: FromZeroes,
u64: FromZeroes,
[u8; 32]: FromZeroes,
[u8; 72]: FromZeroes,
impl FromZeroes for FileHeaderwhere
[u8; 4]: FromZeroes,
u16: FromZeroes,
u64: FromZeroes,
[u8; 32]: FromZeroes,
[u8; 72]: FromZeroes,
impl Copy for FileHeader
Auto Trait Implementations§
impl Freeze for FileHeader
impl RefUnwindSafe for FileHeader
impl Send for FileHeader
impl Sync for FileHeader
impl Unpin for FileHeader
impl UnsafeUnpin for FileHeader
impl UnwindSafe for FileHeader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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