context_async/
with.rs

1use std::future::Future;
2use crate::Context;
3
4#[async_trait::async_trait]
5pub trait With<Output> {
6    async fn with<Ctx>(self, ctx: Ctx) -> crate::Result<Output>
7    where
8        Ctx: Context + Send;
9}
10
11#[async_trait::async_trait]
12impl<'a, Output, Fut> With<Output> for Fut
13where
14    Fut: Future<Output = Output> + Send + 'a
15{
16    async fn with<Ctx>(self, ctx: Ctx) -> crate::Result<Output>
17    where
18        Ctx: Context + Send,
19    {
20        ctx.handle(self).await
21    }
22}