pub struct FileStorage { /* private fields */ }Expand description
JSON storage backed by one file per key, with SHA-256 checksums.
Each file carries a checksum that is verified on load, and filenames are
hashes of the key so arbitrary keys are safe and path traversal is
impossible. The Durability mode controls the write strategy; the default
(FileStorage::open) is Durability::Fast.
Implementations§
Source§impl FileStorage
impl FileStorage
Sourcepub fn open(dir: impl AsRef<Path>) -> StorageResult<Self>
pub fn open(dir: impl AsRef<Path>) -> StorageResult<Self>
Open (creating if necessary) a fast, in-place storage rooted at dir.
Sourcepub fn open_with(
dir: impl AsRef<Path>,
durability: Durability,
) -> StorageResult<Self>
pub fn open_with( dir: impl AsRef<Path>, durability: Durability, ) -> StorageResult<Self>
Open with an explicit Durability mode.
Sourcepub fn durability(&self) -> Durability
pub fn durability(&self) -> Durability
The write-durability mode in effect.
Trait Implementations§
Source§impl Storage for FileStorage
impl Storage for FileStorage
Source§fn save<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: &'life2 Value,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn save<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: &'life2 Value,
) -> Pin<Box<dyn Future<Output = StorageResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Persist
value under key, overwriting any existing entry.Source§fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = StorageResult<Option<Value>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = StorageResult<Option<Value>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load the value stored under
key, or None if absent.Auto Trait Implementations§
impl Freeze for FileStorage
impl RefUnwindSafe for FileStorage
impl Send for FileStorage
impl Sync for FileStorage
impl Unpin for FileStorage
impl UnsafeUnpin for FileStorage
impl UnwindSafe for FileStorage
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