pub struct FileStorage {
pub path: PathBuf,
pub lock_timeout: Duration,
/* private fields */
}Fields§
§path: PathBufRoot directory for all stored data.
lock_timeout: DurationMaximum time to wait when acquiring a lock before returning an error. Defaults to 5 minutes.
Implementations§
Source§impl FileStorage
impl FileStorage
Sourcepub fn new(path: impl Into<PathBuf>) -> FileStorage
pub fn new(path: impl Into<PathBuf>) -> FileStorage
Create a new FileStorage rooted at the given path.
The path does not need to exist yet – directories will be created
on first write. For the platform-appropriate default location, use
FileStorage::default() instead.
Sourcepub fn with_lock_timeout(
path: impl Into<PathBuf>,
lock_timeout: Duration,
) -> FileStorage
pub fn with_lock_timeout( path: impl Into<PathBuf>, lock_timeout: Duration, ) -> FileStorage
Create a new FileStorage with a custom lock timeout.
Trait Implementations§
Source§impl Default for FileStorage
impl Default for FileStorage
Source§fn default() -> FileStorage
fn default() -> FileStorage
Create a FileStorage using the platform-appropriate default data
directory and the default lock timeout.
Source§impl Display for FileStorage
impl Display for FileStorage
Source§impl Storage for FileStorage
impl Storage for FileStorage
Source§fn store<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
FileStorage: 'async_trait,
fn store<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: &'life2 [u8],
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
FileStorage: 'async_trait,
Store
value at key, creating the key if it does not exist and
overwriting any existing value.Source§fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
FileStorage: 'async_trait,
fn load<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
FileStorage: 'async_trait,
Load the value stored at
key. Read moreSource§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
FileStorage: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
FileStorage: 'async_trait,
Delete the named key. If the key is a directory (prefix of other keys),
all keys prefixed by it should be deleted. Read more
Source§fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
FileStorage: 'async_trait,
fn exists<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
FileStorage: 'async_trait,
Returns
true if the key exists (as either a file or directory) and
there was no error checking.Source§fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
recursive: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
FileStorage: 'async_trait,
fn list<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: &'life1 str,
recursive: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<String>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
FileStorage: 'async_trait,
List all keys under
path. Read moreSource§fn stat<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<KeyInfo, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
FileStorage: 'async_trait,
fn stat<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<KeyInfo, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
FileStorage: 'async_trait,
Return metadata about
key. Read moreSource§fn lock<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
FileStorage: 'async_trait,
fn lock<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
FileStorage: 'async_trait,
Acquire a distributed lock for
name, blocking until it can be
obtained or an error occurs. Read moreSource§fn try_lock<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
FileStorage: 'async_trait,
fn try_lock<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
timeout: Duration,
) -> Pin<Box<dyn Future<Output = Result<bool, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
FileStorage: 'async_trait,
Try to acquire a distributed lock for
name with a timeout. Read moreAuto Trait Implementations§
impl !Freeze for FileStorage
impl !RefUnwindSafe for FileStorage
impl !UnwindSafe for FileStorage
impl Send for FileStorage
impl Sync for FileStorage
impl Unpin for FileStorage
impl UnsafeUnpin for FileStorage
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more