pub struct InFlight { /* private fields */ }Expand description
One request that has not finished.
Implementations§
Source§impl InFlight
impl InFlight
Sourcepub fn new(
origin: RequestOrigin,
method: impl AsRef<str>,
token: Option<ProgressToken>,
budget: Option<Duration>,
started_at: Instant,
) -> Self
pub fn new( origin: RequestOrigin, method: impl AsRef<str>, token: Option<ProgressToken>, budget: Option<Duration>, started_at: Instant, ) -> Self
A newly registered request.
budget is how long this side is willing to wait. None means the
caller decided the request is not time-bounded — which is a decision,
not an oversight, and is why it is an Option rather than a zero that
would expire on the next tick.
Sourcepub const fn origin(&self) -> RequestOrigin
pub const fn origin(&self) -> RequestOrigin
Which side issued it.
Sourcepub const fn progress_token(&self) -> Option<&ProgressToken>
pub const fn progress_token(&self) -> Option<&ProgressToken>
The progress token the request carried, if it asked for progress.
Sourcepub const fn budget(&self) -> Option<Duration>
pub const fn budget(&self) -> Option<Duration>
How long this side is willing to wait, if it decided.
Sourcepub const fn started_at(&self) -> Instant
pub const fn started_at(&self) -> Instant
When it was registered.
Sourcepub const fn cancellation(&self) -> &CancellationToken
pub const fn cancellation(&self) -> &CancellationToken
The handle a handler awaits to learn it was cancelled.
Sourcepub fn cancellation_handle(&self) -> CancellationToken
pub fn cancellation_handle(&self) -> CancellationToken
A clone of the cancellation handle, safe to hold across an await.
The registry hands out &InFlight only while its lock is taken, so a
handler that wants to wait has to own the token rather than borrow it
out of the table.
Sourcepub fn has_expired(&self, now: Instant) -> bool
pub fn has_expired(&self, now: Instant) -> bool
Whether the budget is spent at now.
Sourcepub fn advance_progress(
&mut self,
progress: f64,
message: Option<String>,
) -> bool
pub fn advance_progress( &mut self, progress: f64, message: Option<String>, ) -> bool
Records a progress value and says whether it should go on the wire.
false for a request that carried no token, because there is nothing
to correlate the notification to, and for a value that does not move the
cursor forward. Delegates to this entry’s own cursor, so a caller cannot
accidentally check monotonicity against another request’s last value.
Sourcepub const fn furthest_progress(&self) -> Option<f64>
pub const fn furthest_progress(&self) -> Option<f64>
The furthest progress reported for this request.
Sourcepub fn abort(&self, reason: AbortReason) -> bool
pub fn abort(&self, reason: AbortReason) -> bool
Aborts the request.
Returns whether this call is the one that published the reason.