pub struct PreflightHandle<T> { /* private fields */ }Expand description
A future-of-T that has been spawned onto the runtime ahead of
time. The chain calls .await only when it actually needs the
artifact — typically after a cheaper solver has failed.
Implements Future so callers use it identically to a
non-speculative future. Drop = cancel.
Implementations§
Source§impl<T> PreflightHandle<T>where
T: Send + 'static,
impl<T> PreflightHandle<T>where
T: Send + 'static,
Sourcepub fn spawn<F>(fut: F) -> Self
pub fn spawn<F>(fut: F) -> Self
Spawn fut onto the current tokio runtime and return a
handle the chain can .await later.
Panics if called outside a tokio runtime — same constraint
as tokio::spawn. The chain always runs inside one.
Sourcepub fn cancel(self)
pub fn cancel(self)
Cancel the in-flight task without awaiting its result. Idempotent — second call is a no-op. Useful when the chain learns it doesn’t need the artifact (cheap solver won) before the natural drop point.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
True iff the spawned task has finished — useful for “should I bother awaiting, or is the artifact already here?” telemetry checks. Not load-bearing for correctness.
Trait Implementations§
Source§impl<T> Drop for PreflightHandle<T>
impl<T> Drop for PreflightHandle<T>
Source§impl<T> Future for PreflightHandle<T>where
T: Send + 'static,
impl<T> Future for PreflightHandle<T>where
T: Send + 'static,
Source§type Output = Result<T, PreflightError>
type Output = Result<T, PreflightError>
Result<T, PreflightError> so callers can distinguish
“the spawn task panicked” from “T was an error”. For
captchaforge’s use case, T is itself usually a Result,
so the user sees nested Results — that’s the price of
preserving the panic vs business-error distinction.
Auto Trait Implementations§
impl<T> Freeze for PreflightHandle<T>
impl<T> RefUnwindSafe for PreflightHandle<T>
impl<T> Send for PreflightHandle<T>where
T: Send,
impl<T> Sync for PreflightHandle<T>where
T: Send,
impl<T> Unpin for PreflightHandle<T>
impl<T> UnsafeUnpin for PreflightHandle<T>
impl<T> UnwindSafe for PreflightHandle<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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
Source§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
Source§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f. Read moreSource§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
Source§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
Source§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
Source§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll will never again be called once it has
completed. This method can be used to turn any Future into a
FusedFuture. Read moreSource§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
Source§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
Source§fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
() on completion and sends
its output to another future on a separate task. Read moreSource§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
Source§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
Source§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T> into a
TryFuture<Ok = T, Error = ()>.Source§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T> into a
TryFuture<Ok = T, Error = Never>.