pub struct MemoryStorage { /* private fields */ }Expand description
An in-process, non-persistent StateStorage backed by DashMap.
State is lost on process restart. Suitable for development and bots that do not need persistence.
MemoryStorage is Send + Sync + Clone - each clone shares the same
underlying map, so you can hold an Arc<MemoryStorage> or clone freely.
Implementations§
Trait Implementations§
Source§impl Clone for MemoryStorage
impl Clone for MemoryStorage
Source§fn clone(&self) -> MemoryStorage
fn clone(&self) -> MemoryStorage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for MemoryStorage
impl Default for MemoryStorage
Source§fn default() -> MemoryStorage
fn default() -> MemoryStorage
Returns the “default value” for a type. Read more
Source§impl StateStorage for MemoryStorage
impl StateStorage for MemoryStorage
Source§fn get_state<'life0, 'async_trait>(
&'life0 self,
key: StateKey,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_state<'life0, 'async_trait>(
&'life0 self,
key: StateKey,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return the current state key for this slot, or
None if no state is set.Source§fn set_state<'life0, 'async_trait>(
&'life0 self,
key: StateKey,
state: String,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_state<'life0, 'async_trait>(
&'life0 self,
key: StateKey,
state: String,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Persist a new state. Overwrites any previously set state.
Source§fn clear_state<'life0, 'async_trait>(
&'life0 self,
key: StateKey,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear_state<'life0, 'async_trait>(
&'life0 self,
key: StateKey,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Clear the state for this slot. Data is NOT cleared.
Source§fn get_data<'life0, 'life1, 'async_trait>(
&'life0 self,
key: StateKey,
field: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_data<'life0, 'life1, 'async_trait>(
&'life0 self,
key: StateKey,
field: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve a single data field as a raw JSON value.
Source§fn set_data<'life0, 'life1, 'async_trait>(
&'life0 self,
key: StateKey,
field: &'life1 str,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_data<'life0, 'life1, 'async_trait>(
&'life0 self,
key: StateKey,
field: &'life1 str,
value: Value,
) -> Pin<Box<dyn Future<Output = Result<(), StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Persist a single data field as a raw JSON value.
Source§fn get_all_data<'life0, 'async_trait>(
&'life0 self,
key: StateKey,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Value>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_all_data<'life0, 'async_trait>(
&'life0 self,
key: StateKey,
) -> Pin<Box<dyn Future<Output = Result<HashMap<String, Value>, StorageError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Return all data fields stored for this slot.
Auto Trait Implementations§
impl Freeze for MemoryStorage
impl !RefUnwindSafe for MemoryStorage
impl Send for MemoryStorage
impl Sync for MemoryStorage
impl Unpin for MemoryStorage
impl UnsafeUnpin for MemoryStorage
impl !UnwindSafe for MemoryStorage
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