pub mod custom;
pub mod http;
use crate::test::TestState;
use futures::future::BoxFuture;
use std::fmt;
use std::sync::Arc;
pub trait Step: Send + Sync + fmt::Debug {
fn execute<'a>(&'a self, state: &'a TestState) -> BoxFuture<'a, anyhow::Result<()>>;
}
#[derive(Clone)]
pub struct BoxedStep(Arc<dyn Step>);
impl BoxedStep {
pub fn new<S: Step + 'static>(step: S) -> Self {
BoxedStep(Arc::new(step))
}
pub fn execute<'a>(&'a self, state: &'a TestState) -> BoxFuture<'a, anyhow::Result<()>> {
self.0.execute(state)
}
}
impl<S: Step + 'static> From<S> for BoxedStep {
fn from(step: S) -> Self {
BoxedStep::new(step)
}
}
impl fmt::Debug for BoxedStep {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}