pub struct FileStore { /* private fields */ }Expand description
A store in one file, replaced whole on every save.
A save writes a temporary file beside it, flushes it to disk and renames it over the old one, so a crash leaves either the old store or the new, never a mix. On Unix the file is readable by its owner only.
Several processes can share it: lock takes a lock on a
second file beside it, .<name>.lock, which stays there.
Implementations§
Trait Implementations§
Source§impl Store for FileStore
impl Store for FileStore
Source§fn save(&self, json: &str) -> Result<()>
fn save(&self, json: &str) -> Result<()>
Replaces what was saved with
json. Returns only once the data
would survive a crash: the purse hands out keys and transfers only
after this succeeds.Source§fn lock(&self) -> Result<Option<Locked>>
fn lock(&self) -> Result<Option<Locked>>
Locks the store against other processes and reads what is saved in
it, for a store more than one process writes. A purse calls it
before every change: it makes the change to what was read here,
saves, and only then drops the lock, so it never saves over a change
another process made since it last looked. Read more
Auto Trait Implementations§
impl Freeze for FileStore
impl RefUnwindSafe for FileStore
impl Send for FileStore
impl Sync for FileStore
impl Unpin for FileStore
impl UnsafeUnpin for FileStore
impl UnwindSafe for FileStore
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
Mutably borrows from an owned value. Read more