pub trait LocalTask: Future + 'static {
// Required methods
fn result(self) -> impl Future<Output = Result<Self::Output, Error>>;
fn cancel(self);
}
Expand description
A handle to a spawned task that may not be Send
.
Similar to Task
, but for futures that must execute on the same thread
they were spawned on. This is useful for working with non-thread-safe types.
Required Methods§
Sourcefn result(self) -> impl Future<Output = Result<Self::Output, Error>>
fn result(self) -> impl Future<Output = Result<Self::Output, Error>>
Returns the task result or error without panicking.
Similar to Task::result
, but for local tasks that are not Send
.
Sourcefn cancel(self)
fn cancel(self)
Cancels the local task, preventing further execution.
Similar to Task::cancel
, but for local tasks.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.