Skip to main content

Capabilities

Struct Capabilities 

Source
pub struct Capabilities {
    pub atomic_replace: bool,
    pub sync_guarantee: SyncGuarantee,
    pub native_transactions: bool,
}
Expand description

The durability guarantees a Storage backend can make — declared by the backend through Storage::capabilities, honored by prov’s crash-safety machinery.

The point of naming these explicitly is that prov must run correctly over backends that keep very different promises. Rather than assume a guarantee and corrupt data on the backend that cannot keep it, prov reads the capabilities and picks the strongest protocol the backend actually supports: a filesystem gets atomic-rename writes and a journal; a transactional store is handed the whole change set to commit itself; a backend that can promise neither still works, it simply cannot claim a write survives a crash.

Fields§

§atomic_replace: bool

The backend can replace an existing file’s contents in one indivisible step, so no crash exposes a half-written file — an observer sees the whole old contents or the whole new. On a filesystem this is realized by Storage::write_atomic’s write-temp-then-rename; a backend may instead be atomic by nature.

§sync_guarantee: SyncGuarantee

How strong the backend’s Storage::sync is: whether it can flush at all, and if so whether a flush merely orders writes or carries them through a power cut. fsync on std::fs, FileSystemSyncAccessHandle .flush() on OPFS, the implicit durability of a committed IndexedDB transaction.

§native_transactions: bool

The backend commits changes to many objects as one indivisible unit, so prov’s own write-ahead journal would be redundant and it should defer to the backend instead. True for IndexedDB; false for a plain filesystem, where multi-file atomicity is prov’s job to provide.

Implementations§

Source§

impl Capabilities

Source

pub const NONE: Self

Promises nothing — the safe assumption for an unknown backend, and the Storage::capabilities default. Every field is the pessimistic value, so code that checks a capability before relying on it takes the most defensive branch unless a backend has explicitly earned a lighter one.

Source

pub const LOCAL_FS: Self

A conventional local filesystem: atomic replacement by rename and durable fsync, but no native multi-object transaction (that is the journal’s job). What StdFs reports on every platform prov targets.

Source

pub const IN_MEMORY: Self

An in-process, memory-only store (InMemoryFs): every mutation takes the backend’s single lock for its whole duration, so one write already swaps old bytes for new as one indivisible step — no separate temp-then-rename dance is needed for atomic_replace to be true. But nothing here is backed by anything other than process memory, so its sync_guarantee is SyncGuarantee::None: there is nothing to flush, and the entire store evaporates the instant the process exits — it cannot even promise ordering against a crash it will not survive. native_transactions is false too — the lock makes each single call atomic, not a batch of several calls committed together, so a multi-file change set still needs prov’s own journal over this backend exactly as it would over a real filesystem.

Trait Implementations§

Source§

impl Clone for Capabilities

Source§

fn clone(&self) -> Capabilities

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 Capabilities

Source§

impl Debug for Capabilities

Source§

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

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

impl Eq for Capabilities

Source§

impl PartialEq for Capabilities

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Capabilities

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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 = Infallible

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.