pub struct DiskCacheConfig {
pub dir: PathBuf,
pub hmac_key: [u8; 32],
}Expand description
Configuration for the on-disk L2 cache.
The cache directory must be writable by the runtime user and SHOULD be
owned exclusively by that user (mode 0700 on Unix) — operators on a
hardened deployment can additionally chattr +i files after first
write so a parallel attacker process cannot tamper with cached
entries even with the same UID.
hmac_key is the secret that gates load: the writer HMACs each
persisted entry with the key, and the reader rejects any file whose
recomputed HMAC does not match. Without the key (or with a different
key) the loader treats every existing entry as a miss, so rotating
the key invalidates the disk cache without requiring an rm -rf.
The caller-supplied hmac_key field is plain [u8; 32] for ergonomic
construction; once handed to KernelCache::with_disk_persistence the
bytes are copied into a private Zeroizing<[u8; 32]> inside
DiskCache which wipes them on drop. The caller’s own copy is the
caller’s responsibility (e.g. construct via Zeroizing::new upstream
and let it drop after the call).
jit S-3 hardening (T13): Debug is implemented manually so the
hmac_key bytes are redacted in any {:?} formatting, panic message,
or tracing field expansion — the derived Debug would have dumped
the raw 32-byte array. Drop zeroizes hmac_key on drop so the
construction-time copy does not survive in freed memory.
Fields§
§dir: PathBufDirectory where the L2 cache files live. Created lazily on first
put.
hmac_key: [u8; 32]32-byte HMAC-keyed-BLAKE3 key. MUST be process-stable across the cache’s lifetime and SHOULD be treated as a server-side secret. The long-lived copy held by the cache is zeroized on drop; this field is the construction-time hand-off only.
jit S-3 (T13): redacted in the manual std::fmt::Debug impl
below and zeroized in Drop so the construction-time copy
does not linger in freed memory after the value is moved into
the long-lived DiskCache.
Trait Implementations§
Source§impl Clone for DiskCacheConfig
impl Clone for DiskCacheConfig
Source§fn clone(&self) -> DiskCacheConfig
fn clone(&self) -> DiskCacheConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DiskCacheConfig
impl Debug for DiskCacheConfig
Source§impl Drop for DiskCacheConfig
impl Drop for DiskCacheConfig
Auto Trait Implementations§
impl Freeze for DiskCacheConfig
impl RefUnwindSafe for DiskCacheConfig
impl Send for DiskCacheConfig
impl Sync for DiskCacheConfig
impl Unpin for DiskCacheConfig
impl UnsafeUnpin for DiskCacheConfig
impl UnwindSafe for DiskCacheConfig
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more