pub struct Context<S> { /* private fields */ }
Expand description
Context is used to manage state and data of the user in specified storage
Implementations§
source§impl<S> Context<S>where
S: Storage,
impl<S> Context<S>where
S: Storage,
sourcepub async fn set_previous_state(&self) -> Result<(), S::Error>
pub async fn set_previous_state(&self) -> Result<(), S::Error>
sourcepub async fn get_states(&self) -> Result<Box<[Box<str>]>, S::Error>
pub async fn get_states(&self) -> Result<Box<[Box<str>]>, S::Error>
Get states stack
§Errors
If storage error occurs, when get states stack
§Notes
States stack is used to store states history, when user set new state, then current state will be push to the states stack, so you can use this method to get states history or back to the previous state
§Returns
States, if states is no exists, then empty slice will be return
sourcepub async fn remove_states(&self) -> Result<(), S::Error>
pub async fn remove_states(&self) -> Result<(), S::Error>
sourcepub async fn set_value<Key, Value>(
&self,
value_key: Key,
value: Value,
) -> Result<(), S::Error>
pub async fn set_value<Key, Value>( &self, value_key: Key, value: Value, ) -> Result<(), S::Error>
sourcepub async fn get_data<Data>(&self) -> Result<HashMap<Box<str>, Data>, S::Error>where
Data: DeserializeOwned,
pub async fn get_data<Data>(&self) -> Result<HashMap<Box<str>, Data>, S::Error>where
Data: DeserializeOwned,
sourcepub async fn get_value<Key, Value>(
&self,
value_key: Key,
) -> Result<Option<Value>, S::Error>
pub async fn get_value<Key, Value>( &self, value_key: Key, ) -> Result<Option<Value>, S::Error>
sourcepub async fn remove_data(&self) -> Result<(), S::Error>
pub async fn remove_data(&self) -> Result<(), S::Error>
sourcepub async fn finish(&self) -> Result<(), S::Error>
pub async fn finish(&self) -> Result<(), S::Error>
Finish current context by remove state and data.
This method is just shortcut for Context::remove_states
and Context::remove_data
methods
§Errors
If storage error occurs, when remove state or data
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for Context<S>where
S: Freeze,
impl<S> RefUnwindSafe for Context<S>where
S: RefUnwindSafe,
impl<S> Send for Context<S>where
S: Send,
impl<S> Sync for Context<S>where
S: Sync,
impl<S> Unpin for Context<S>where
S: Unpin,
impl<S> UnwindSafe for Context<S>where
S: UnwindSafe,
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