Header

Struct Header 

Source
#[repr(C, align(64))]
pub struct Header {
Show 17 fields pub magic: [u8; 4], pub version: u32, pub checksum: u32, pub total_size: u32, pub str_blob_size: u32, pub regex_blob_size: u32, pub str_table_count: u16, pub regex_table_count: u16, pub node_types_count: u16, pub node_fields_count: u16, pub trivia_count: u16, pub type_defs_count: u16, pub type_members_count: u16, pub type_names_count: u16, pub entrypoints_count: u16, pub transitions_count: u16, pub _reserved: [u8; 20],
}
Expand description

File header - first 64 bytes of the bytecode file.

v3 layout (offsets computed from counts):

  • 0-23: identity and sizes (magic, version, checksum, total_size, str_blob_size, regex_blob_size)
  • 24-43: counts (10 × u16) — order matches section order
  • 44-63: reserved

Fields§

§magic: [u8; 4]

Magic bytes: b“PTKQ“

§version: u32

Format version (currently 3)

§checksum: u32

CRC32 checksum of everything after the header

§total_size: u32

Total file size in bytes

§str_blob_size: u32

Size of the string blob in bytes.

§regex_blob_size: u32

Size of the regex blob in bytes.

§str_table_count: u16§regex_table_count: u16§node_types_count: u16§node_fields_count: u16§trivia_count: u16§type_defs_count: u16§type_members_count: u16§type_names_count: u16§entrypoints_count: u16§transitions_count: u16§_reserved: [u8; 20]

Implementations§

Source§

impl Header

Source

pub fn from_bytes(bytes: &[u8]) -> Self

Decode header from 64 bytes.

Source

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

Encode header to 64 bytes.

Source

pub fn validate_magic(&self) -> bool

Source

pub fn validate_version(&self) -> bool

Source

pub fn compute_offsets(&self) -> SectionOffsets

Compute section offsets from counts and blob sizes.

Section order (all 64-byte aligned): Header → StringBlob → RegexBlob → StringTable → RegexTable → NodeTypes → NodeFields → Trivia → TypeDefs → TypeMembers → TypeNames → Entrypoints → Transitions

Trait Implementations§

Source§

impl Clone for Header

Source§

fn clone(&self) -> Header

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 Header

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Header

Source§

fn default() -> Self

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

impl PartialEq for Header

Source§

fn eq(&self, other: &Header) -> 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 Header

Source§

impl Eq for Header

Source§

impl StructuralPartialEq for Header

Auto Trait Implementations§

§

impl Freeze for Header

§

impl RefUnwindSafe for Header

§

impl Send for Header

§

impl Sync for Header

§

impl Unpin for Header

§

impl UnwindSafe for Header

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> 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.