pub enum NarResidency {
Streaming,
Capped(usize),
WholeValue,
}Expand description
What a backend’s NAR path costs in resident memory.
Every StorageBackend implementor must state this — it has no default.
That is the mechanism, not decoration: the streaming verbs
(get_nar_stream /
put_nar_stream) do carry a buffering
fallback so a test double stays a few lines, and without a required
declaration a new production backend could silently inherit it and
reintroduce the OOM. Making the declaration mandatory means adding a backend
without deciding is a compile error, and shipping a production backend
that declares WholeValue is caught by
[every_production_backend_bounds_its_nar_path] in CI.
Tier-honest: this is parse-time-rejected (you cannot omit the decision) plus CI-gate-caught (you cannot ship the wrong one from the factory). It is not truly-unrepresentable — the buffering code path still exists and a hand-constructed backend may use it.
Variants§
Streaming
O(chunk). The backend never holds more than NAR_CHUNK_BYTES of a
NAR, whatever the NAR’s size.
Capped(usize)
O(min(nar, cap)). Bounded by a configured cap; a NAR past the cap is
refused (StoreError::TooLarge), never buffered. The hot-tier shape:
a cap is a real bound because the durable tiers below still take the
write.
WholeValue
O(nar). The whole NAR is materialized. Legal only for in-memory test doubles and small-value stores — never for a tier that serves real builds.
Implementations§
Source§impl NarResidency
impl NarResidency
Sourcepub const fn is_bounded(self) -> bool
pub const fn is_bounded(self) -> bool
Whether the peak is bounded independently of NAR size.
Sourcepub fn weaker(self, other: NarResidency) -> NarResidency
pub fn weaker(self, other: NarResidency) -> NarResidency
The weaker of two residencies — the honest answer for a composite backend, whose real cost is its worst tier’s.
Order: Streaming (best) < Capped < WholeValue (worst); two
Cappeds compose to the larger cap, because either one may be the one
that holds the bytes.
Trait Implementations§
Source§impl Clone for NarResidency
impl Clone for NarResidency
Source§fn clone(&self) -> NarResidency
fn clone(&self) -> NarResidency
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for NarResidency
Source§impl Debug for NarResidency
impl Debug for NarResidency
impl Eq for NarResidency
Source§impl PartialEq for NarResidency
impl PartialEq for NarResidency
impl StructuralPartialEq for NarResidency
Auto Trait Implementations§
impl Freeze for NarResidency
impl RefUnwindSafe for NarResidency
impl Send for NarResidency
impl Sync for NarResidency
impl Unpin for NarResidency
impl UnsafeUnpin for NarResidency
impl UnwindSafe for NarResidency
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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