Skip to main content

Header

Struct Header 

Source
pub struct Header {
    pub magic: [u8; 4],
    pub version: (u8, u8),
    pub model_type: ModelType,
    pub metadata_size: u32,
    pub payload_size: u32,
    pub uncompressed_size: u32,
    pub compression: Compression,
    pub flags: Flags,
    pub quality_score: u8,
}
Expand description

File header (32 bytes).

Fields§

§magic: [u8; 4]

Magic number (must be “APRN”)

§version: (u8, u8)

Format version (major, minor)

§model_type: ModelType

Model type identifier

§metadata_size: u32

Metadata section size in bytes

§payload_size: u32

Compressed payload size in bytes

§uncompressed_size: u32

Uncompressed payload size (for allocation check)

§compression: Compression

Compression algorithm

§flags: Flags

Feature flags

§quality_score: u8

Quality score (0-100, Poka-yoke validation) - APR-POKA-001 0 = no validation (F), 1-59 = failing, 60-100 = passing grades

Implementations§

Source§

impl Header

Source

pub fn new(model_type: ModelType) -> Self

Create a new header.

Source

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

Serialize header to bytes (32 bytes).

Source

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

Parse header from bytes.

§Errors

Returns an error on short input, bad magic, unsupported version, unknown model type, unknown compression, or a compression-bomb-sized payload.

Trait Implementations§

Source§

impl Clone for Header

Source§

fn clone(&self) -> Header

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 Header

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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, <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.