Skip to main content

SceneCache

Struct SceneCache 

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

Bounded deterministic compile-once/render-many scene cache.

Implementations§

Source§

impl SceneCache

Source

pub const DEFAULT_MAX_BYTES: usize

Default aggregate serialized scene budget.

Source

pub fn new(capacity: usize) -> Result<Self>

Creates a cache with an explicit non-zero entry bound.

Source

pub fn with_byte_capacity(capacity: usize, max_bytes: usize) -> Result<Self>

Bounds cached and evicted-but-consumer-held scenes by entries and aggregate serialized bytes. Returned Arc copies outside this cache, including Arc::make_mut allocations, are not process memory accounting.

Source

pub fn get(&self, key: &DocumentFingerprint) -> Option<Arc<ResolvedScene>>

Returns an immutable cached scene without changing eviction order.

Source

pub fn get_or_try_insert_with<F>( &mut self, key: DocumentFingerprint, limits: &ResourceLimits, resolve: F, ) -> Result<Arc<ResolvedScene>>
where F: FnOnce() -> Result<ResolvedScene>,

Returns a cached scene or resolves and inserts it exactly once on a miss. Rejects a miss before resolving when consumer-held scenes exhaust the entry or serialized-byte bound. This is not a scratch-memory reservation.

Source

pub fn insert( &mut self, key: DocumentFingerprint, scene: ResolvedScene, limits: &ResourceLimits, ) -> Result<Arc<ResolvedScene>>

Inserts a fully resolved scene and evicts the oldest inserted key. Evicted scenes held by consumers still consume entry/byte admission. If leases prevent admission, returns LimitExceeded; earlier FIFO evictions may already have occurred. Compilation scratch is not covered.

Source

pub fn len(&self) -> usize

Number of retained scenes.

Source

pub fn is_empty(&self) -> bool

Returns whether no scenes are retained.

Source

pub const fn used_bytes(&self) -> usize

Aggregate serialized bytes retained by cached scenes.

Source

pub fn retired_bytes(&self) -> usize

Serialized bytes of evicted scenes still held by consumers (not RSS). Counts are observed per entry; concurrent consumer drops may lower them.

Source

pub const fn max_bytes(&self) -> usize

Configured aggregate serialized scene byte budget.

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> Finish for T

Source§

fn finish(self)

Does nothing but move self, equivalent to drop.
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<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

Source§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
Source§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

Source§

fn to_owned_table(&self) -> U

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.