pub struct MutAppStateLock<'a, T: ?Sized>(/* private fields */);Expand description
The lock guard for a mutable app state.
This is a wrapper around MutexGuard.
When this guard is dropped, the lock will be released.
As this locks the state, no other thread can access the state until this guard is dropped.
§Examples
use app_state::{MutAppState, MutAppStateLock, AppStateTrait, stateful};
struct MyState {
counter: u32,
}
#[stateful]
fn func(mut state: MutAppStateLock<MyState>) {
state.counter += 1;
}Implementations§
Source§impl<'a, T: 'static + Send> MutAppStateLock<'a, T>
impl<'a, T: 'static + Send> MutAppStateLock<'a, T>
pub fn new(inner: &'a MutAppState<T>) -> MutAppStateLock<'a, T>
Source§impl<'a, T: ?Sized> MutAppStateLock<'a, T>
impl<'a, T: ?Sized> MutAppStateLock<'a, T>
Sourcepub fn get_ref(&self) -> &MutexGuard<'a, T>
pub fn get_ref(&self) -> &MutexGuard<'a, T>
Returns reference to inner T.
Sourcepub fn into_inner(self) -> MutexGuard<'a, T>
pub fn into_inner(self) -> MutexGuard<'a, T>
Unwraps to the internal Arc<T>
Trait Implementations§
Source§impl<'a, T: ?Sized> Deref for MutAppStateLock<'a, T>
impl<'a, T: ?Sized> Deref for MutAppStateLock<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for MutAppStateLock<'a, T>where
T: ?Sized,
impl<'a, T> RefUnwindSafe for MutAppStateLock<'a, T>where
T: ?Sized,
impl<'a, T> !Send for MutAppStateLock<'a, T>
impl<'a, T> Sync for MutAppStateLock<'a, T>
impl<'a, T> Unpin for MutAppStateLock<'a, T>where
T: ?Sized,
impl<'a, T> UnwindSafe for MutAppStateLock<'a, T>where
T: ?Sized,
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