1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//! Wait-On library to wait on the availability of resources
//! such as Files, HTTP Servers, Ports & Sockets

pub mod resource;

use anyhow::Result;

pub type Millis = u64;

/// Options available for waiting on a [`Waitable`].
#[derive(Debug, Default)]
pub struct WaitOptions {
    /// Timeout in milliseconds for the wait operation.
    pub timeout: Option<Millis>,
}

/// A [`Waitable`] is an resource that can be waited on.
///
/// Every [`Resource`] must implement this trait.
///
/// # Should not be implemented by the user
///
/// This trait should not be implemented by the user, instead, it should be
/// implemented by the [`Resource`] enum variants in the `lib` scope.
#[allow(async_fn_in_trait)]
pub trait Waitable {
    async fn wait(self, options: WaitOptions) -> Result<()>;
}