Crate situwaition
source ·Expand description
Situwaition
This library makes it easy to wait for a situation (cutely named “situWAITion”) to complete.
Situwaition can be used in contexts with or without async runtimes, and generally does what you’d expect (tm):
use situwaition::wait_for;
fn main() -> Result<(), Box<dyn Error>> {
let value = 0;
let result: Result<&str> = wait_for(|| match value == 5 {
true => Ok("done!"),
false => {
value += 1; // NOTE: incrementing like this only works in a single threaded context!
Err("not yet")
},
});
}
The example above demonstrates the synchronous usage, but tokio
and async-std
and corresponding modules are available as well.
Re-exports
pub use sync::wait_for;
Modules
Structs
- Options for a given situwaition
- Builder for
SituwaitionOpts
.
Enums
- The type of error that is thrown when
- Error type for SituwaitionOptsBuilder
- Errors that are thrown during waiter creation
Traits
- This trait represents a “situwaition” that can be a“waited“, with async-std. note that how the waiting is done can differ by platform
- The basic requirements of any situwaition
- Synchronously executed situwaitions
- This trait represents a “situwaition” that can be a“waited“, with tokio. note that how the waiting is done can differ by platform