Skip to main content

FileHeader

Struct FileHeader 

Source
pub struct FileHeader {
Show 15 fields pub magic: [u8; 4], pub version: u32, pub dimension: u32, pub language_count: u32, pub unit_count: u64, pub edge_count: u64, pub unit_table_offset: u64, pub edge_table_offset: u64, pub string_pool_offset: u64, pub feature_vec_offset: u64, pub temporal_offset: u64, pub index_offset: u64, pub repo_hash: [u8; 32], pub compiled_at: u64, pub _reserved: [u8; 8],
}
Expand description

Header of an .acb file. Fixed size: 128 bytes.

Layout (all fields little-endian):

  • 0x00: magic [u8; 4]
  • 0x04: version u32
  • 0x08: dimension u32
  • 0x0C: language_count u32
  • 0x10: unit_count u64
  • 0x18: edge_count u64
  • 0x20: unit_table_offset u64
  • 0x28: edge_table_offset u64
  • 0x30: string_pool_offset u64
  • 0x38: feature_vec_offset u64
  • 0x40: temporal_offset u64
  • 0x48: index_offset u64
  • 0x50: repo_hash [u8; 32]
  • 0x70: compiled_at u64
  • 0x78: _reserved [u8; 8]

Fields§

§magic: [u8; 4]

Magic bytes: must be [0x41, 0x43, 0x44, 0x42] (“ACDB”).

§version: u32

Format version (currently 1).

§dimension: u32

Feature vector dimensionality.

§language_count: u32

Number of supported languages in this file.

§unit_count: u64

Total number of code units.

§edge_count: u64

Total number of edges.

§unit_table_offset: u64

Byte offset to code unit table.

§edge_table_offset: u64

Byte offset to edge table.

§string_pool_offset: u64

Byte offset to string pool.

§feature_vec_offset: u64

Byte offset to feature vectors.

§temporal_offset: u64

Byte offset to temporal block.

§index_offset: u64

Byte offset to index block.

§repo_hash: [u8; 32]

Repository root path hash (for cache validation).

§compiled_at: u64

Compilation timestamp (Unix epoch microseconds).

§_reserved: [u8; 8]

Reserved for future use.

Implementations§

Source§

impl FileHeader

Source

pub fn new(dimension: u32) -> Self

Create a new header with sensible defaults and the given dimension.

Source

pub fn write_to(&self, w: &mut impl Write) -> AcbResult<()>

Write the header to a byte writer (little-endian).

Source

pub fn read_from(r: &mut impl Read) -> AcbResult<Self>

Read a header from a byte reader (little-endian).

§Errors
  • AcbError::InvalidMagic if magic bytes don’t match.
  • AcbError::UnsupportedVersion if version is not recognized.
  • AcbError::Io on read failure.
Source

pub fn to_bytes(&self) -> [u8; 128]

Serialize the header to a 128-byte array.

Source

pub fn from_bytes(data: &[u8; 128]) -> AcbResult<Self>

Deserialize a header from a 128-byte slice.

Trait Implementations§

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 PartialEq for FileHeader

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for FileHeader

Source§

impl StructuralPartialEq 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> 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> 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<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