Skip to main content

FiberHandle

Struct FiberHandle 

Source
pub struct FiberHandle<A, E> { /* private fields */ }
Expand description

Runtime-owned handle to a spawned fiber.

Completion is backed by Deferred (watch-channel rendezvous). Self::join and Self::await_exit surface completion; Self::await_exit returns the full Exit value.

Implementations§

Source§

impl<A, E> FiberHandle<A, E>
where A: Clone + Send + Sync + 'static, E: Clone + Send + Sync + 'static,

Source

pub fn pending(id: FiberId) -> Self

Handle for a fiber not yet completed (waits on internal Deferred).

Source

pub fn completed(id: FiberId, result: Result<A, E>) -> Self

Handle already completed with result.

Source

pub fn id(&self) -> FiberId

Fiber id assigned at creation.

Source

pub fn mark_completed(&self, result: Result<A, E>)

Complete the underlying deferred with result (for tests / manual drivers).

Source

pub fn interrupt(&self) -> bool

Fail the fiber with Cause::Interrupt. Returns false if already completed.

Source

pub fn status(&self) -> FiberStatus

Running vs terminal outcome (blocking poll of the deferred).

Source

pub fn is_done(&self) -> bool

Source

pub fn poll(&self) -> Effect<Option<Exit<A, E>>, Never, ()>

Non-blocking read of the current Exit, if the fiber has completed.

Source

pub fn poll_result(&self) -> Option<Result<A, Cause<E>>>

Snapshot for callers that want the legacy Option<Result<_, Cause>> shape: None while running or when the stored exit is an interrupt (matches older FiberHandle::poll).

Source

pub fn await_exit(&self) -> Effect<Exit<A, E>, Never, ()>

Wait for completion and return the full Exit (success or failure Cause).

Source

pub async fn join(&self) -> Result<A, Cause<E>>

Await completion and map to Result (interrupt surfaces as Cause::Interrupt).

Source

pub fn map<B>( self, f: impl Fn(A) -> B + Send + Sync + 'static, ) -> FiberHandle<B, E>
where B: Clone + Send + Sync + 'static,

Map a successful value after this fiber completes (spawns a background join on the tokio runtime).

Source

pub fn zip<B>(self, other: FiberHandle<B, E>) -> FiberHandle<(A, B), E>
where B: Clone + Send + Sync + 'static,

Zip two fibers; both must succeed. The first failure Cause wins.

Source

pub fn zip_with<B, C, F>( self, other: FiberHandle<B, E>, f: F, ) -> FiberHandle<C, E>
where B: Clone + Send + Sync + 'static, C: Clone + Send + Sync + 'static, F: Fn(A, B) -> C + Send + Sync + 'static,

Like Self::zip, then combine success values with f.

Source

pub fn or_else(self, other: FiberHandle<A, E>) -> FiberHandle<A, E>

Race: complete with whichever fiber finishes first (the other keeps running for other waiters).

Source

pub fn scoped(self) -> Effect<A, Cause<E>, Scope>

Register a scope finalizer that interrupts this fiber on scope close, then await completion under the given Scope environment.

Source

pub fn interrupt_fork(&self) -> Effect<(), Never, ()>

Request interrupt from the async runtime without blocking the caller.

Trait Implementations§

Source§

impl<A: Clone, E: Clone> Clone for FiberHandle<A, E>

Source§

fn clone(&self) -> FiberHandle<A, E>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<A: Debug, E: Debug> Debug for FiberHandle<A, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<A, E> Freeze for FiberHandle<A, E>

§

impl<A, E> RefUnwindSafe for FiberHandle<A, E>

§

impl<A, E> Send for FiberHandle<A, E>
where A: Send + Sync, E: Send + Sync,

§

impl<A, E> Sync for FiberHandle<A, E>
where A: Send + Sync, E: Send + Sync,

§

impl<A, E> Unpin for FiberHandle<A, E>

§

impl<A, E> UnsafeUnpin for FiberHandle<A, E>

§

impl<A, E> UnwindSafe for FiberHandle<A, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pipe for T

Source§

fn pipe<F, R>(self, f: F) -> R
where F: FnOnce(Self) -> R,

Applies f to self (F#-style forward pipe).
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.