Struct PrefixedState
pub struct PrefixedState<'a> { /* private fields */ }Expand description
A borrowed view of state that automatically prepends a prefix to all keys.
Implementations§
§impl<'a> PrefixedState<'a>
impl<'a> PrefixedState<'a>
pub fn get<T>(&self, key: &str) -> Option<T>where
T: DeserializeOwned,
pub fn get<T>(&self, key: &str) -> Option<T>where
T: DeserializeOwned,
Get a value by key (with prefix applied).
pub fn with<F, R>(&self, key: &str, f: F) -> Option<R>
pub fn with<F, R>(&self, key: &str, f: F) -> Option<R>
Zero-copy borrow a value by key (with prefix applied).
pub fn set(
&self,
key: impl AsRef<str>,
value: impl Serialize,
) -> Result<(), StateError>
pub fn set( &self, key: impl AsRef<str>, value: impl Serialize, ) -> Result<(), StateError>
Set a value by key (with prefix applied).
Returns StateError if value cannot be serialized to JSON.
Auto Trait Implementations§
impl<'a> Freeze for PrefixedState<'a>
impl<'a> !RefUnwindSafe for PrefixedState<'a>
impl<'a> Send for PrefixedState<'a>
impl<'a> Sync for PrefixedState<'a>
impl<'a> Unpin for PrefixedState<'a>
impl<'a> !UnwindSafe for PrefixedState<'a>
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