use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use async_trait::async_trait;
use uuid::Uuid;
pub type ScopedWork<'a> = Pin<Box<dyn Future<Output = ()> + Send + 'a>>;
#[async_trait]
pub trait MailingRunScope: Send + Sync {
async fn within<'a>(&'a self, mailing_id: Uuid, work: ScopedWork<'a>) -> Result<(), String>;
}
pub struct Unscoped;
#[async_trait]
impl MailingRunScope for Unscoped {
async fn within<'a>(&'a self, _mailing_id: Uuid, work: ScopedWork<'a>) -> Result<(), String> {
work.await;
Ok(())
}
}
pub fn unscoped() -> Arc<dyn MailingRunScope> {
Arc::new(Unscoped)
}