Skip to main content

Durability

Enum Durability 

Source
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

Source§

fn clone(&self) -> Durability

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Durability

Source§

impl Debug for Durability

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Durability

Source§

impl Ord for Durability

Source§

fn cmp(&self, other: &Durability) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Durability

Source§

fn eq(&self, other: &Durability) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Durability

Source§

fn partial_cmp(&self, other: &Durability) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Durability

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.