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: ManifestImplementations§
Source§impl MmapBundle
impl MmapBundle
Sourcepub fn open(path: &Path) -> Result<Self>
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.
Sourcepub fn lookup(&self, entry_key: &[u8; 32]) -> Option<&[u8]>
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.
Sourcepub fn lookup_preferred(
&self,
entry_key: &[u8; 32],
preferences: &[u16],
) -> Option<&[u8]>
pub fn lookup_preferred( &self, entry_key: &[u8; 32], preferences: &[u16], ) -> Option<&[u8]>
Look up the best-matching entry given preferred discriminators.
Sourcepub fn manifest_bytes(&self) -> &[u8] ⓘ
pub fn manifest_bytes(&self) -> &[u8] ⓘ
Get the raw manifest bytes (slice into mmap).
Sourcepub fn seal_bytes(&self) -> &[u8] ⓘ
pub fn seal_bytes(&self) -> &[u8] ⓘ
Get the raw seal bytes (slice into mmap).
Sourcepub fn entry_count(&self) -> usize
pub fn entry_count(&self) -> usize
Number of index records.