pub struct UpdateResult<S, M> {
pub state: Option<S>,
pub command: Command<M>,
}Expand description
Result of an update operation.
This provides a convenient way to return both state changes and commands from an update function.
Fields§
§state: Option<S>The updated state (if changed)
command: Command<M>Commands to execute
Implementations§
Source§impl<S, M> UpdateResult<S, M>
impl<S, M> UpdateResult<S, M>
Sourcepub fn with(state: S, command: Command<M>) -> Self
pub fn with(state: S, command: Command<M>) -> Self
Creates a result with both state and command.
Sourcepub fn and_command(self, command: Command<M>) -> Self
pub fn and_command(self, command: Command<M>) -> Self
Adds a command to this result.
Sourcepub fn map_state<T, F>(self, f: F) -> UpdateResult<T, M>where
F: FnOnce(S) -> T,
pub fn map_state<T, F>(self, f: F) -> UpdateResult<T, M>where
F: FnOnce(S) -> T,
Maps the state type.
Sourcepub fn map_message<N, F>(self, f: F) -> UpdateResult<S, N>
pub fn map_message<N, F>(self, f: F) -> UpdateResult<S, N>
Maps the message type.
Trait Implementations§
Auto Trait Implementations§
impl<S, M> Freeze for UpdateResult<S, M>where
S: Freeze,
impl<S, M> !RefUnwindSafe for UpdateResult<S, M>
impl<S, M> Send for UpdateResult<S, M>
impl<S, M> !Sync for UpdateResult<S, M>
impl<S, M> Unpin for UpdateResult<S, M>
impl<S, M> UnsafeUnpin for UpdateResult<S, M>where
S: UnsafeUnpin,
impl<S, M> !UnwindSafe for UpdateResult<S, M>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more