pub struct SceneCache { /* private fields */ }Expand description
Bounded deterministic compile-once/render-many scene cache.
Implementations§
Source§impl SceneCache
impl SceneCache
Sourcepub const DEFAULT_MAX_BYTES: usize
pub const DEFAULT_MAX_BYTES: usize
Default aggregate serialized scene budget.
Sourcepub fn new(capacity: usize) -> Result<Self>
pub fn new(capacity: usize) -> Result<Self>
Creates a cache with an explicit non-zero entry bound.
Sourcepub fn with_byte_capacity(capacity: usize, max_bytes: usize) -> Result<Self>
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.
Sourcepub fn get(&self, key: &DocumentFingerprint) -> Option<Arc<ResolvedScene>>
pub fn get(&self, key: &DocumentFingerprint) -> Option<Arc<ResolvedScene>>
Returns an immutable cached scene without changing eviction order.
Sourcepub fn get_or_try_insert_with<F>(
&mut self,
key: DocumentFingerprint,
limits: &ResourceLimits,
resolve: F,
) -> Result<Arc<ResolvedScene>>
pub fn get_or_try_insert_with<F>( &mut self, key: DocumentFingerprint, limits: &ResourceLimits, resolve: F, ) -> Result<Arc<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.
Sourcepub fn insert(
&mut self,
key: DocumentFingerprint,
scene: ResolvedScene,
limits: &ResourceLimits,
) -> Result<Arc<ResolvedScene>>
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.
Sourcepub const fn used_bytes(&self) -> usize
pub const fn used_bytes(&self) -> usize
Aggregate serialized bytes retained by cached scenes.
Sourcepub fn retired_bytes(&self) -> usize
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.
Auto Trait Implementations§
impl Freeze for SceneCache
impl RefUnwindSafe for SceneCache
impl Send for SceneCache
impl Sync for SceneCache
impl Unpin for SceneCache
impl UnsafeUnpin for SceneCache
impl UnwindSafe for SceneCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.