Skip to main content

PayloadStore

Trait PayloadStore 

Source
pub trait PayloadStore {
    // Required methods
    fn read(&mut self, locator: &PayloadLocator) -> Result<&[u8], CnResult>;
    fn release(&mut self, blob_index: u32);
    fn disk_backed(&self) -> bool;

    // Provided method
    fn release_all_resident(&mut self) -> usize { ... }
}
Expand description

A source of compiled payload bytes addressed by PayloadLocator.

Required Methods§

Source

fn read(&mut self, locator: &PayloadLocator) -> Result<&[u8], CnResult>

Read the bytes a locator points at. &mut self because a disk-backed store may load an overflow section lazily on first access. Errors when the payload was released, the locator is out of range, or a lazy load fails.

Source

fn release(&mut self, blob_index: u32)

Release an entire blob’s in-memory payload once every system that needs it has finished (e.g. after GPU upload). A store with nothing resident for blob_index treats this as a no-op.

Source

fn disk_backed(&self) -> bool

Whether the payloads are backed by files still on disk, so a released payload can be re-read on demand rather than kept RAM-resident.

Provided Methods§

Source

fn release_all_resident(&mut self) -> usize

Release every resident section at once, returning the bytes freed. World::start calls this after init: systems read compiled payloads only while initing and cache what they keep, so nothing consults the store again. A store with nothing resident frees nothing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§