pub enum ConnectionClass {
Unmetered,
Metered,
Constrained,
Adverse,
Offline,
}Expand description
The closed connection-class enum, evaluated continuously on-device. Consumers: sync criteria (small/large reconciliation), staged-upload tier gates, the cache-eviction byte budget, prefetch, adaptive chunk sizing.
Variants§
Unmetered
Bulk transfer is acceptable.
Metered
Byte-counted link; bulk work is deferred.
Constrained
OS-level data saver (iOS Low Data Mode / Android Data Saver).
Adverse
Connectivity present but unreliable — behavioral promotion on repeated mid-transfer resets/stalls within a sliding window; demoted after a clean period. No OS reports this class; it is derived.
Offline
No usable path.
Implementations§
Source§impl ConnectionClass
impl ConnectionClass
Sourcepub fn from_signals(signals: PathSignals) -> Self
pub fn from_signals(signals: PathSignals) -> Self
Map sampled OS signals to the base class, before any behavioral
promotion to ConnectionClass::Adverse (which no OS reports — see
AdverseDetector).
Precedence is deliberate and total: no path ⇒ offline; else data saver
⇒ constrained (the strongest user “minimize data” signal wins over a
merely metered link); else an expensive / not-explicitly-unmetered link ⇒
metered; else unmetered. constrained and metered are always
distinguished (networking doc Validation: “class detection”).
Sourcepub fn is_usable(self) -> bool
pub fn is_usable(self) -> bool
Whether any usable path exists (every class but ConnectionClass::Offline).
Sourcepub fn is_non_metered(self) -> bool
pub fn is_non_metered(self) -> bool
Whether the link is treated as non-metered for tier and reconciliation gating.
Only ConnectionClass::Unmetered qualifies: its definition is precisely
“bulk transfer is acceptable”. ConnectionClass::Metered (byte-counted)
and ConnectionClass::Constrained (data saver) are byte-conscious, and
ConnectionClass::Adverse is unreliable — so above-index tiers defer on
all three, matching the tier ladder’s “even constrained/adverse” T0 row and
the adverse posture’s “the staged-upload T0 index still escapes over the
thin link”.
Sourcepub fn permits_tier(self, tier: UploadTier, force_sync: bool) -> bool
pub fn permits_tier(self, tier: UploadTier, force_sync: bool) -> bool
Whether a staged-upload tier may open on this connection.
Mirrors the download/upload tier ladder (transfer upload doc, “Upload
Tiering”): T0 index escapes on any usable connection (a few KB per asset);
T1 preview and T2 original need a non-metered link — or an explicit
user-consented force_sync, which overrides the metered/Wi-Fi criteria but
never resurrects an offline path.
Sourcepub fn permits_reconciliation(
self,
class: ReconciliationClass,
force_sync: bool,
) -> bool
pub fn permits_reconciliation( self, class: ReconciliationClass, force_sync: bool, ) -> bool
Whether a reconciliation of the given size may run now (sync criteria:
small vs. large). Small (a handful of assets / metadata deltas) and large
(bulk originals) both require a non-metered link; force_sync is the
two-week-staleness “force sync now” consent that overrides it. The extra
deferral of a large reconciliation (idle/on-power scheduling) is the
scheduler’s concern, layered above this connection gate.
Sourcepub fn cache_retention_budget(self, base_budget_bytes: u64) -> u64
pub fn cache_retention_budget(self, base_budget_bytes: u64) -> u64
The cache-eviction byte budget for this class, from a base budget.
The budget is the ceiling of cache bytes the client retains before the
last-access eviction sweep (owned by Filesystem — Client) reclaims space.
It scales inversely with re-fetch cost: on an ConnectionClass::Unmetered
link re-fetching an evicted blob is cheap, so the client keeps the tight
base budget and evicts freely; on byte-conscious, unreliable, or offline
links re-fetch is expensive or impossible, so it retains more. The
multipliers are client-tunable policy, not protocol surface; only their
monotonicity (unmetered ≤ metered/constrained ≤ adverse ≤ offline) is a
contract.
Sourcepub fn range_window(self) -> Option<u64>
pub fn range_window(self) -> Option<u64>
The bounded Range window a blob fetch uses on this class, or None
for the open-ended remainder.
Adverse-network posture (networking doc, “Bounded transfer windows under
adverse”): only ConnectionClass::Adverse shrinks fetches to a bounded
window (ADVERSE_RANGE_WINDOW) so each request is small enough to usually
complete between mid-transfer resets; every other class fetches the whole
remaining range in one request (None). The window size is client-tunable
policy, not protocol surface.
Trait Implementations§
Source§impl Clone for ConnectionClass
impl Clone for ConnectionClass
Source§fn clone(&self) -> ConnectionClass
fn clone(&self) -> ConnectionClass
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 ConnectionClass
Source§impl Debug for ConnectionClass
impl Debug for ConnectionClass
impl Eq for ConnectionClass
Source§impl PartialEq for ConnectionClass
impl PartialEq for ConnectionClass
Source§fn eq(&self, other: &ConnectionClass) -> bool
fn eq(&self, other: &ConnectionClass) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ConnectionClass
Auto Trait Implementations§
impl Freeze for ConnectionClass
impl RefUnwindSafe for ConnectionClass
impl Send for ConnectionClass
impl Sync for ConnectionClass
impl Unpin for ConnectionClass
impl UnsafeUnpin for ConnectionClass
impl UnwindSafe for ConnectionClass
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,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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