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
impl ProgressHandle
Sourcepub fn token(&self) -> ProgressToken
pub fn token(&self) -> ProgressToken
The progress token allocated for this operation.
Sourcepub fn cancellation_token(&self) -> CancellationToken
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.
Sourcepub fn report(
&self,
message: Option<String>,
percentage: Option<u32>,
) -> Result<(), ClientError>
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.
Sourcepub fn end(self, message: Option<String>) -> Result<(), ClientError>
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.