pub struct FsStateMgr { /* private fields */ }
Expand description

Implementation of StateMgr that stores state as JSON files on disk.

Locking

This manager uses a lock file to determine whether it’s allowed to write to the disk. Only one process should write to the disk at a time, though any number may read from the disk.

By default, every FsStateMgr starts out unlocked, and only able to read. Use FsStateMgr::try_lock() to lock it.

Limitations

  1. This manager only accepts objects that can be serialized as JSON documents. Some types (like maps with non-string keys) can’t be serialized as JSON.

  2. This manager normalizes keys to an fs-safe format before saving data with them. This keeps you from accidentally creating or reading files elsewhere in the filesystem, but it doesn’t prevent collisions when two keys collapse to the same fs-safe filename. Therefore, you should probably only use ascii keys that are fs-safe on all systems.

NEVER use user-controlled or remote-controlled data for your keys.

Implementations

Construct a new FsStateMgr to store data in path.

This function will try to create path if it does not already exist.

Return the top-level directory for this storage manager.

(This is the same directory passed to FsStateMgr::from_path.)

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Return true if this is a read-write state manager. Read more

Try to become a read-write state manager if possible, without blocking. Read more

Release any locks held and become a read-only state manager again. If no locks were held, do nothing. Read more

Try to load the object with key key from the store. Read more

Try to save val with key key in the store. Read more

Make a new StorageHandle to store values of particular type at a particular key. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.