Skip to main content

ProgressHandle

Struct ProgressHandle 

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

The connection-scoped handle for one work-done progress operation, created by Client::begin_progress.

The handle reports through ProgressHandle::report and finishes through ProgressHandle::end, which consumes it. Dropping an active handle removes its token from the connection’s registry and logs a warning, but performs no I/O: no implicit end notification is sent.

Implementations§

Source§

impl ProgressHandle

Source

pub fn token(&self) -> ProgressToken

The progress token allocated for this operation.

Source

pub fn cancellation_token(&self) -> CancellationToken

The handle’s cancellation token.

User code may cancel it directly; the protocol engine’s window/workDoneProgress/cancel built-in cancels it when the user cancels a cancellable progress in the client UI. Cancellation never sends anything by itself: reports on a cancelled handle fail with ProgressError::Cancelled and the application still decides the final message and calls ProgressHandle::end.

Source

pub fn report( &self, message: Option<String>, percentage: Option<u32>, ) -> Result<(), ClientError>

Enqueue one work-done report notification with the exact WorkDoneProgressReport shape: the handle’s cancellable flag plus the given message and percentage.

§Errors

ClientError::Progress wrapping ProgressError::AlreadyEnded, ProgressError::Cancelled, or ProgressError::UnknownToken for a handle whose lifecycle already concluded, and ProgressError::InvalidPercentage for a percentage outside 0 through 100 — none of these send anything. Enqueue failures surface as the other ClientError variants.

Source

pub fn end(self, message: Option<String>) -> Result<(), ClientError>

Enqueue one work-done end notification and remove the token from the connection’s registry, consuming the handle.

The token is removed after the enqueue whether it succeeded or failed, so the handle never leaks its registry entry. A cancelled handle still ends: cancellation never sends an implicit end by itself.

§Errors

Enqueue failures surface as ClientError; the token is removed regardless.

Trait Implementations§

Source§

impl Debug for ProgressHandle

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for ProgressHandle

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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