Trait Condition

Source
pub trait Condition<H>:
    Debug
    + Clone
    + 'static {
    type Arguments: ParseArguments<H>;

    // Required methods
    fn check_now(
        &self,
        harness: &H,
        arguments: &Self::Arguments,
    ) -> Result<bool>;
    fn wait_until(
        &self,
        harness: &H,
        arguments: &Self::Arguments,
    ) -> Result<bool>;
}
Expand description

A condition check for a given property

Conditions allow to check for anything you would find useful. For example, in a HTTP library, you can check that your cache contains a valid entry from a previous request.

Required Associated Types§

Source

type Arguments: ParseArguments<H>

The arguments for this condition

Required Methods§

Source

fn check_now(&self, harness: &H, arguments: &Self::Arguments) -> Result<bool>

Run the check now, may or may not actually be implemented

This is only useful for non-transient properties. For example “is this connected”. It is not a way to check for events.

If the condition cannot properly support the concept of ‘checking now’ it is ok to simply return an error.

Source

fn wait_until(&self, harness: &H, arguments: &Self::Arguments) -> Result<bool>

Wait until a given condition evaluates to a meaningful value

Some properties of a system are not meaningful other than ‘that they happened’. This could be an event or some value changing.

If the condition cannot properly support the concept of ‘waiting until it has a value’, it is ok to simply return an error.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<H, T> Condition<H> for FunctionCondition<H, T>
where H: 'static, T: ParseArguments<H>,