Skip to main content

CompletionTracker

Struct CompletionTracker 

Source
pub struct CompletionTracker { /* private fields */ }
Expand description

Tracks completion of a single message across all handlers.

§Semantics

The handler_count at send time determines expected. This is “best effort” - handlers registered concurrently with a send may or may not be counted. Document explicitly: send awaits approximately the current handler count; handlers added concurrently may or may not be accounted for.

Implementations§

Source§

impl CompletionTracker

Source

pub fn new(expected: usize) -> Self

Create a new tracker expecting expected handlers to complete.

Note: expected is a snapshot at send time. Handlers registered concurrently may not be included in this count.

Source

pub fn expected(&self) -> usize

Get the expected count.

Source

pub fn completed(&self) -> usize

Get the completed count.

Source

pub fn is_complete(&self) -> bool

Check if all handlers have completed.

Source

pub fn complete_one(&self)

Signal successful completion of one handler.

Calling this more than once per handler is a logic error but is handled gracefully (extra completions are ignored after the expected count is reached).

Source

pub fn fail(&self, error: RelayError)

Signal failure with an error.

Source

pub fn take_error(&self) -> Option<RelayError>

Take the error if one occurred.

Source

pub fn wait(&self) -> CompletionFuture<'_>

Returns a future that completes when all handlers have finished.

This is the proper way to await completion - it’s a pollable future that doesn’t spawn tasks from within poll().

Source

pub async fn wait_async(&self)

Async method to wait for completion.

Alternative to wait() for use in async contexts where you want to await directly.

Source§

impl CompletionTracker

Source

pub async fn wait_owned(self: Arc<Self>)

Returns an owned future that completes when all handlers have finished.

This version takes Arc<Self> and returns a 'static future that can be stored in a state machine.

Trait Implementations§

Source§

impl Debug for CompletionTracker

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more