pub struct StateMut<G, T, S>where
G: DerefMut<Target = SharedValue<T>>,{ /* private fields */ }Expand description
Mutable typed view into shared state.
Transitions performed through this guard update an internal pending state. When the guard is dropped, that pending state is committed back to the shared container.
The returned guard is used through the generic State alias
SMutView, so implementation methods can keep the same
State<S, Self, Current> receiver shape they use for owned values:
ⓘ
{
let connected = shared.borrow_mut::<Connected>()?;
let authenticated = magicstatemachines::transition!(
connected,
"alice".to_owned(),
);
drop(authenticated); // shared state is now `Authenticated`
}The commit happens when the final guard state is dropped. Constructing a transition call object is not a commit by itself.
Trait Implementations§
Auto Trait Implementations§
impl<G, T, S> !RefUnwindSafe for StateMut<G, T, S>
impl<G, T, S> !Send for StateMut<G, T, S>
impl<G, T, S> !StateClone for StateMut<G, T, S>
impl<G, T, S> !StateCopy for StateMut<G, T, S>
impl<G, T, S> !Sync for StateMut<G, T, S>
impl<G, T, S> !UnwindSafe for StateMut<G, T, S>
impl<G, T, S> Freeze for StateMut<G, T, S>where
G: Freeze,
impl<G, T, S> Unpin for StateMut<G, T, S>where
G: Unpin,
impl<G, T, S> UnsafeUnpin for StateMut<G, T, S>where
G: UnsafeUnpin,
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