Crate situwaition

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§

runtime
sync

Structs§

SituwaitionOpts
Options for a given situwaition
SituwaitionOptsBuilder
Builder for SituwaitionOpts.

Enums§

SituwaitionError
The type of error that is thrown when
SituwaitionOptsBuilderError
Error type for SituwaitionOptsBuilder
WaiterCreationError
Errors that are thrown during waiter creation

Traits§

AsyncStdAsyncSituwaition
This trait represents a “situwaition” that can be a“waited“, with async-std. note that how the waiting is done can differ by platform
SituwaitionBase
The basic requirements of any situwaition
SyncSituwaition
Synchronously executed situwaitions
TokioAsyncSituwaition
This trait represents a “situwaition” that can be a“waited“, with tokio. note that how the waiting is done can differ by platform