pub trait Store:
Clone
+ Send
+ Sync {
type Error: Debug;
type Key: Send + Clone;
type Value: Value;
type Count: Send + Clone;
// Required methods
fn incr_by<'life0, 'async_trait>(
&'life0 self,
key: Self::Key,
val: Self::Count,
) -> Pin<Box<dyn Future<Output = Result<Self::Value, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn incr<'life0, 'async_trait>(
&'life0 self,
key: Self::Key,
) -> Pin<Box<dyn Future<Output = Result<Self::Value, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn del<'life0, 'async_trait>(
&'life0 self,
key: Self::Key,
) -> Pin<Box<dyn Future<Output = Result<Option<Self::Value>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Required Associated Types§
Sourcetype Error: Debug
type Error: Debug
[Error] represents possible errors that may occur during the execution of a function.
Sourcetype Value: Value
type Value: Value
Value is a structure used to represent values, such as the current count and the initial time.
Sourcetype Count: Send + Clone
type Count: Send + Clone
Alias of Value::Count.
Required Methods§
Sourcefn incr_by<'life0, 'async_trait>(
&'life0 self,
key: Self::Key,
val: Self::Count,
) -> Pin<Box<dyn Future<Output = Result<Self::Value, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn incr_by<'life0, 'async_trait>(
&'life0 self,
key: Self::Key,
val: Self::Count,
) -> Pin<Box<dyn Future<Output = Result<Self::Value, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The [incr_by] function takes a [Key] and an unsigned integer, indicating the amount by which the index should be incremented.
The function returns the result of the incremented count.
Sourcefn incr<'life0, 'async_trait>(
&'life0 self,
key: Self::Key,
) -> Pin<Box<dyn Future<Output = Result<Self::Value, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn incr<'life0, 'async_trait>(
&'life0 self,
key: Self::Key,
) -> Pin<Box<dyn Future<Output = Result<Self::Value, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The [incr] function is a wrapper for the [incr_by] function, with val = 1.
Sourcefn del<'life0, 'async_trait>(
&'life0 self,
key: Self::Key,
) -> Pin<Box<dyn Future<Output = Result<Option<Self::Value>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn del<'life0, 'async_trait>(
&'life0 self,
key: Self::Key,
) -> Pin<Box<dyn Future<Output = Result<Option<Self::Value>, Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The [del] function deletes the storage of the index [Key] and returns the count result before deletion.
Sourcefn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
The [clear] function clears all cached data.
This function is not mandatory; if Store does not need to clear cached data (for example, when stored in Redis or a relational database, bulk clearing of data is slow and unnecessary), the function can do nothing.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.