pub struct DryContext { /* private fields */ }Expand description
DryContext contains only serializable data values
Implementations§
Source§impl DryContext
impl DryContext
pub fn new() -> Self
pub fn with_value<T: Serialize>(self, key: impl Into<String>, value: T) -> Self
pub fn insert<T: Serialize>(&mut self, key: impl Into<String>, value: T)
pub fn get<T: for<'de> Deserialize<'de>>(&self, key: &str) -> Option<T>
pub fn get_required<T: for<'de> Deserialize<'de>>( &self, key: &str, ) -> Result<T, OpError>
pub fn contains(&self, key: &str) -> bool
pub fn keys(&self) -> impl Iterator<Item = &String>
pub fn values(&self) -> &HashMap<String, Value>
Sourcepub fn get_or_insert_with<T, F>(
&mut self,
key: &str,
factory: F,
) -> Result<T, OpError>
pub fn get_or_insert_with<T, F>( &mut self, key: &str, factory: F, ) -> Result<T, OpError>
Get a value or insert it using a factory closure if it doesn’t exist
Sourcepub fn get_or_compute_with<T, F>(
&mut self,
key: &str,
computer: F,
) -> Result<T, OpError>
pub fn get_or_compute_with<T, F>( &mut self, key: &str, computer: F, ) -> Result<T, OpError>
Get a value or compute it using a closure that has access to the context
Sourcepub async fn ensure<T, F>(
&mut self,
key: &str,
wet: &mut WetContext,
factory: F,
) -> Result<T, OpError>
pub async fn ensure<T, F>( &mut self, key: &str, wet: &mut WetContext, factory: F, ) -> Result<T, OpError>
Get a value or compute it using a closure that has access to the context The closure receives mutable access to the context and the key, and must insert the value itself
pub fn merge(&mut self, other: DryContext)
Sourcepub fn is_aborted(&self) -> bool
pub fn is_aborted(&self) -> bool
Check if abort flag is set
Sourcepub fn abort_reason(&self) -> Option<&String>
pub fn abort_reason(&self) -> Option<&String>
Get abort reason if set
Sourcepub fn clear_control_flags(&mut self)
pub fn clear_control_flags(&mut self)
Clear all control flags
Trait Implementations§
Source§impl Clone for DryContext
impl Clone for DryContext
Source§fn clone(&self) -> DryContext
fn clone(&self) -> DryContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DryContext
impl Debug for DryContext
Source§impl Default for DryContext
impl Default for DryContext
Source§fn default() -> DryContext
fn default() -> DryContext
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for DryContext
impl<'de> Deserialize<'de> for DryContext
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for DryContext
impl RefUnwindSafe for DryContext
impl Send for DryContext
impl Sync for DryContext
impl Unpin for DryContext
impl UnsafeUnpin for DryContext
impl UnwindSafe for DryContext
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