Skip to main content

Store

Trait Store 

Source
pub trait Store<S> {
    // Required methods
    fn with<R, F>(&self, act: F) -> Result<R>
       where F: FnOnce(&mut S) -> Result<R>;
    fn snapshot(&self) -> Result<S>;
}
Expand description

A provider’s state, however it is kept.

Required Methods§

Source

fn with<R, F>(&self, act: F) -> Result<R>
where F: FnOnce(&mut S) -> Result<R>,

Read the state, act on it, and keep whatever the action left.

One call rather than a read and a write, so a file-backed provider’s read-modify-write is atomic from a caller’s point of view and an action that fails leaves the state it started from.

Source

fn snapshot(&self) -> Result<S>

The state as it stands.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§