pub enum Durability {
Ordered,
Durable,
}Expand description
What a caller needs from one Storage::sync call — the weakest guarantee
that is still correct at that point, so that a backend able to serve it
cheaply is free to.
Variants§
Ordered
A barrier: everything this backend was asked to write before this call — to the named path or to any other — must land before anything written after it. It says nothing about when: a crash may still lose the lot, only never a suffix without its prefix.
The barrier is backend-wide on purpose, not scoped to the one path
named. Storage::write_atomic only needs the narrow reading — the
rename must not be seen before the bytes it publishes — but
crate::ordered builds on the wide one: a batch whose second tier
must never be seen without its first is ordering writes to different
files against each other, and a “barrier” that only ordered a file
against itself could not say that. Both fsync (which completes the
named writes outright) and Apple’s F_BARRIERFSYNC (a queue barrier
the whole device honors) keep the wide promise; a primitive that
orders only one file’s own writes — sync_file_range and its kin —
does not, and a backend with nothing stronger must declare
SyncGuarantee::None rather than a barrier it cannot keep. On Apple
platforms the distinction from Durable is the
difference between a barrier and draining the drive’s write cache.
The wide promise has a corollary the journal protocols lean on: once any later write is durably on disk, everything ordered before it is too — a barrier followed by one durable flush of what that later write mutated makes the whole prefix durable, without flushing it piece by piece.
Durable
Once the call returns, the bytes survive power loss.
And not the named path’s bytes alone: on a backend whose
Ordered answers are true barriers rather than
flushes, a Durable answer is contractually a drain — everything
the backend accepted and barriered before this call lands durably with
it. This is the other half of the barrier’s bargain, and it is not
derivable from ordering alone: a batch that barriers ten paths and
drains an eleventh has issued no write after the barriers for pure
ordering to hang the ten on. Both primitives this crate ships keep the
pair honestly — plain fsync because every “barrier” was a full flush
to begin with, F_FULLFSYNC because it drains the device’s whole
cache — and a backend that can only drain the named object must answer
Ordered with a flush rather than a barrier, or declare
SyncGuarantee::None. The batched-flush protocols in this crate
(barriers capped by one drain) are licensed by this pairing.
Trait Implementations§
Source§impl Clone for Durability
impl Clone for Durability
Source§fn clone(&self) -> Durability
fn clone(&self) -> Durability
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more