Skip to main content

MmapBundle

Struct MmapBundle 

Source
pub struct MmapBundle {
    pub header: FileHeader,
    pub manifest: Manifest,
    /* private fields */
}
Expand description

A memory-mapped ahu bundle for zero-copy serving at scale.

Uses MAP_PRIVATE (copy-on-write). The backing inode must remain immutable: publish replacements with atomic rename, never truncate an open bundle. The OS demand-pages only the regions actually accessed — a 45 GB bundle uses ~200 MB RSS under typical access patterns.

The index is searched via binary search directly in the mapped region. Response bytes are returned as slices into the mapping — no allocation.

Fields§

§header: FileHeader§manifest: Manifest

Implementations§

Source§

impl MmapBundle

Source

pub fn open(path: &Path) -> Result<Self>

Open a bundle file with MAP_PRIVATE (copy-on-write).

§Safety

Uses unsafe for the mmap syscall. Publishers must replace files atomically; MAP_PRIVATE does not protect against truncation. Size is validated against header offsets before any section is accessed.

Source

pub fn lookup(&self, entry_key: &[u8; 32]) -> Option<&[u8]>

Look up an entry by its entry key (SHA-256 of DER CertID). Returns the default (discriminator=0) entry.

Source

pub fn lookup_preferred( &self, entry_key: &[u8; 32], preferences: &[u16], ) -> Option<&[u8]>

Look up the best-matching entry given preferred discriminators.

Source

pub fn manifest_bytes(&self) -> &[u8] ⓘ

Get the raw manifest bytes (slice into mmap).

Source

pub fn seal_bytes(&self) -> &[u8] ⓘ

Get the raw seal bytes (slice into mmap).

Source

pub fn entry_count(&self) -> usize

Number of index records.

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

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

§

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

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,