enough
Minimal cooperative cancellation trait for Rust.
A minimal, no_std trait for cooperative cancellation. Zero dependencies.
StopReason is 1 byte and check() compiles to a single boolean read from the stack.
For Library Authors
Accept impl Stop in your functions:
use ;
Zero-Cost Default
use Never;
// Compiles away completely - zero runtime cost
let result = decode;
What's in This Crate
This crate provides only the core trait and types:
Stop- The cooperative cancellation traitStopReason- Why an operation stopped (Cancelled or TimedOut)Never- Zero-cost "never stop" implementation
For concrete cancellation implementations (Stopper, StopSource, timeouts, etc.), see almost-enough.
Features
- None (default) -
no_stdcore:Stoptrait,StopReason,Never alloc- AddsBox<T>andArc<T>blanket impls forStopstd- Impliesalloc. Addsstd::error::Errorimpl forStopReason
See Also
almost-enough- All implementations:Stopper,StopSource,ChildStopper, timeouts, combinators, guardsenough-ffi- FFI helpers for C#, Python, Node.jsenough-tokio- Tokio CancellationToken bridge
License
MIT OR Apache-2.0