pub trait ProgressSink: Send + Sync {
// Required method
fn notify(
&self,
token: ProgressToken,
progress: u64,
total: Option<u64>,
message: Option<&str>,
);
// Provided method
fn new_token(&self) -> ProgressToken { ... }
}Expand description
Sink that receives progress emissions from a running tool.
Implementations must be cheap to clone/share (Send + Sync) because the
same sink may be handed to many tool invocations concurrently. All methods
take &self; internal synchronization is the sink’s responsibility.
Required Methods§
Sourcefn notify(
&self,
token: ProgressToken,
progress: u64,
total: Option<u64>,
message: Option<&str>,
)
fn notify( &self, token: ProgressToken, progress: u64, total: Option<u64>, message: Option<&str>, )
Emit a progress event.
token: correlates this event with an operation.progress: current work completed (monotonically non-decreasing).total: optional total units of work, if known up front.message: optional human-readable status string.
Provided Methods§
Sourcefn new_token(&self) -> ProgressToken
fn new_token(&self) -> ProgressToken
Allocate a fresh progress token for a new operation.
The default implementation hands out monotonically increasing tokens starting at 0; real sinks (e.g. MCP) will typically override this to mint tokens that match an inbound request ID.