pub enum ProgressToken {
Number(i64),
Text(Arc<str>),
}Expand description
The opaque handle a request carries to ask for progress updates.
§Why this is the second non-Copy newtype
crate::domain::RequestId is not Copy because it wraps an Arc<str>,
and this does too, for the same reason: a progress token is stored on the
in-flight entry when the request arrives and read again for every update
until it completes, so a notification re-uses the request’s allocation
instead of making one. RequestId’s doc comment says it is the only such
newtype; this is the one exception, and it is the same reason rather than a
new one — a token duplicated by value is a correlation the peer did not ask
for.
Variants§
Implementations§
Source§impl ProgressToken
impl ProgressToken
Sourcepub fn from_json(value: &Value) -> Option<Self>
pub fn from_json(value: &Value) -> Option<Self>
Reads a token out of the JSON a request carried.
The one place the wire shape is known, and it is the shape the vendored
schema states: a string or a number, nothing else. A boolean, an object
or a fractional number is not a ProgressToken, and returning None
for one is what lets the request proceed with no progress rather than
failing — the token is a request for updates, not a requirement for the
request to be valid.