Struct rat_salsa::AppContext
source · pub struct AppContext<'a, Global, Action, Error>{
pub g: &'a mut Global,
pub timeout: Option<TimeOut>,
/* private fields */
}Expand description
A collection of context data used by the application.
Fields§
§g: &'a mut GlobalSome global state for the application.
timeout: Option<TimeOut>Current timeout, if any.
Implementations§
source§impl<'a, Global, Action, Error> AppContext<'a, Global, Action, Error>
impl<'a, Global, Action, Error> AppContext<'a, Global, Action, Error>
sourcepub fn add_timer(&self, t: TimerDef) -> TimerHandle
pub fn add_timer(&self, t: TimerDef) -> TimerHandle
Add a timer.
sourcepub fn remove_timer(&self, tag: TimerHandle)
pub fn remove_timer(&self, tag: TimerHandle)
Remove a timer.
sourcepub fn spawn(
&self,
task: impl FnOnce(Cancel, &Sender<Result<Control<Action>, Error>>) -> Result<Control<Action>, Error> + Send + 'static,
) -> Result<Cancel, SendError<()>>
pub fn spawn( &self, task: impl FnOnce(Cancel, &Sender<Result<Control<Action>, Error>>) -> Result<Control<Action>, Error> + Send + 'static, ) -> Result<Cancel, SendError<()>>
Add a background worker task.
ⓘ
let cancel = ctx.spawn(|cancel, send| {
// ... do stuff
Ok(Control::Continue)
});sourcepub fn queue_result(&self, ctrl: Result<Control<Action>, Error>)
pub fn queue_result(&self, ctrl: Result<Control<Action>, Error>)
Queue additional results.
Trait Implementations§
Auto Trait Implementations§
impl<'a, Global, Action, Error> Freeze for AppContext<'a, Global, Action, Error>
impl<'a, Global, Action, Error> !RefUnwindSafe for AppContext<'a, Global, Action, Error>
impl<'a, Global, Action, Error> !Send for AppContext<'a, Global, Action, Error>
impl<'a, Global, Action, Error> !Sync for AppContext<'a, Global, Action, Error>
impl<'a, Global, Action, Error> Unpin for AppContext<'a, Global, Action, Error>
impl<'a, Global, Action, Error> !UnwindSafe for AppContext<'a, Global, Action, Error>
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