pub struct CancellationToken { /* private fields */ }Expand description
The signal a caller trips to stop a turn.
Re-exported rather than restated, and the reason is the one thing basis cannot
wrap: a token is an identity, not a value. The turn holds one half and the
caller the other, and a basis-owned copy would have to forward the trip to
mentra’s — a second object that can disagree with the first about whether
the stop button was pressed. So this is a deliberate leak, like
ModelSelector and
BuiltinProvider on
RuntimeBuilder.
Re-exporting it is what makes the leak cheap. A host embedding basis
should not have to add mentra to its own manifest — and pin the same
version — to name a type basis’s own API asks it for; a skew there fails to
compile with no hint that two crates disagree about one struct. Hence the
rule: every mentra type basis’s surface makes a caller name, basis re-exports.
Two of them go on a turn and they mean different things —
TurnOptions::cancel abandons it, TurnOptions::stop ends it
gracefully.
A shared flag a caller trips to stop a run.
Debug prints whether it has been tripped, so a host that embeds one in
its own options struct can still derive Debug on that struct.
Implementations§
Source§impl CancellationToken
impl CancellationToken
pub fn cancel(&self)
pub fn is_cancelled(&self) -> bool
Trait Implementations§
Source§impl Clone for CancellationToken
impl Clone for CancellationToken
Source§fn clone(&self) -> CancellationToken
fn clone(&self) -> CancellationToken
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more