Struct LatestRequest
pub struct LatestRequest<T> { /* private fields */ }Expand description
UI-thread inbox for worker results where only the newest request may win.
The owner keeps this value inside its table/list/domain model. Calling
Self::begin invalidates every older completion; an accepted completion
wakes the application and is drained with Self::try_take. This keeps
channels, event-loop proxies, and generation races out of app models.
Implementations§
§impl<T> LatestRequest<T>
impl<T> LatestRequest<T>
pub fn new() -> LatestRequest<T>
pub fn begin(&mut self) -> RequestCompletion<T>
pub fn begin(&mut self) -> RequestCompletion<T>
Start a request, invalidating any older completion capability.
After the generation namespace is exhausted this returns a permanently
stale capability which cannot publish. This preserves the original
infallible API without aliasing a live generation; long-lived hosts that
need to observe exhaustion can use Self::try_begin.
pub fn try_begin(&mut self) -> Option<RequestCompletion<T>>
pub fn try_begin(&mut self) -> Option<RequestCompletion<T>>
Fallible form of Self::begin. Returns None without changing state
when the captured owner is closed or no unique completion generation
remains.
pub fn cancel(&mut self)
pub fn cancel(&mut self)
Invalidate outstanding work without publishing a replacement.
At the terminal invalidation marker this is a safe no-op because no
completion capability is ever issued for that reserved generation. Use
Self::try_cancel when the caller needs to observe exhaustion.
pub fn try_cancel(&mut self) -> bool
pub fn try_cancel(&mut self) -> bool
Fallible form of Self::cancel. Returns false only after the
terminal invalidation marker has already been reached.
pub fn is_pending(&self) -> bool
§impl<T> LatestRequest<T>where
T: Send + 'static,
impl<T> LatestRequest<T>where
T: Send + 'static,
pub fn spawn<F>(&mut self, future: F) -> bool
pub fn spawn<F>(&mut self, future: F) -> bool
Start a request whose result is future’s output.
The future runs on the app runtime (tilo_rt::app), never on the
calling UI thread. Its output wakes the event loop and is drained with
Self::try_take. A newer request, a cancellation or dropping this
inbox aborts the future at its next await point.
Returns false without spawning when the owner is closed or the
generation namespace is exhausted (see Self::try_begin).
Trait Implementations§
§impl<T> Default for LatestRequest<T>
impl<T> Default for LatestRequest<T>
§fn default() -> LatestRequest<T>
fn default() -> LatestRequest<T>
§impl<T> Drop for LatestRequest<T>
impl<T> Drop for LatestRequest<T>
Auto Trait Implementations§
impl<T> Freeze for LatestRequest<T>
impl<T> RefUnwindSafe for LatestRequest<T>
impl<T> Send for LatestRequest<T>where
T: Send,
impl<T> !Sync for LatestRequest<T>
impl<T> Unpin for LatestRequest<T>
impl<T> UnsafeUnpin for LatestRequest<T>
impl<T> UnwindSafe for LatestRequest<T>
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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