Skip to main content

SectionTable

Struct SectionTable 

Source
pub struct SectionTable { /* private fields */ }
Expand description

The section table containing all section entries

Implementations§

Source§

impl SectionTable

Source

pub fn new() -> SectionTable

Create an empty section table

Source

pub fn with_capacity(capacity: usize) -> SectionTable

Create with pre-allocated capacity

Source

pub fn push(&mut self, entry: SectionEntry)

Add a section entry

Source

pub fn len(&self) -> usize

Get number of sections

Source

pub fn is_empty(&self) -> bool

Check if table is empty

Source

pub fn get(&self, index: usize) -> Option<&SectionEntry>

Get entry by index

Source

pub fn get_by_name_index(&self, name_index: u8) -> Option<&SectionEntry>

Get entry by its string-table name index

Source

pub fn entries(&self) -> &[SectionEntry]

Get all entries

Source

pub fn entries_by_priority(&self) -> Vec<&SectionEntry>

Get entries sorted by priority (highest first)

Source

pub fn entries_within_budget(&self, budget: u16) -> Vec<&SectionEntry>

Get entries that fit within a token budget by dropping whole priority tiers from the tail (64, then 128, then 150–200). Original table order is preserved. Critical (255) entries always remain.

This is prefix truncation, not priority-first greedy: a hole in canonical order is not a rendering of this Content ID.

Source

pub fn total_tokens(&self) -> u32

Calculate total token count

Source

pub fn table_size(&self) -> usize

Calculate total size in bytes (for section table only)

Source

pub fn write<W>(&self, writer: &mut W) -> Result<(), FafbError>
where W: Write,

Write section table to a byte buffer

Source

pub fn to_bytes(&self) -> Result<Vec<u8>, FafbError>

Write section table to a new Vec<u8>

Source

pub fn read<R>(reader: &mut R, count: usize) -> Result<SectionTable, FafbError>
where R: Read,

Read section table from a byte buffer

Source

pub fn from_bytes(data: &[u8], count: usize) -> Result<SectionTable, FafbError>

Read section table from a byte slice

Source

pub fn validate_bounds(&self, file_size: u32) -> Result<(), FafbError>

Validate all entries against file size

Trait Implementations§

Source§

impl Clone for SectionTable

Source§

fn clone(&self) -> SectionTable

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 SectionTable

Source§

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

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

impl Default for SectionTable

Source§

fn default() -> SectionTable

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

impl IntoIterator for SectionTable

Source§

type Item = SectionEntry

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<SectionEntry>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <SectionTable as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for &'a SectionTable

Source§

type Item = &'a SectionEntry

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, SectionEntry>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <&'a SectionTable as IntoIterator>::IntoIter

Creates an iterator from a value. 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<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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.