use crate::extract::FromJobCallParts;
use crate::job::call::Parts;
use core::future::Future;
mod sealed {
pub trait Sealed {}
impl Sealed for crate::job::call::Parts {}
}
pub trait JobCallPartsExt: sealed::Sealed + Sized {
fn extract<E>(&mut self) -> impl Future<Output = Result<E, E::Rejection>> + Send
where
E: FromJobCallParts<()> + 'static;
fn extract_with_ctx<'a, E, Ctx>(
&'a mut self,
ctx: &'a Ctx,
) -> impl Future<Output = Result<E, E::Rejection>> + Send + 'a
where
E: FromJobCallParts<Ctx> + 'static,
Ctx: Send + Sync;
}
impl JobCallPartsExt for Parts {
fn extract<E>(&mut self) -> impl Future<Output = Result<E, E::Rejection>> + Send
where
E: FromJobCallParts<()> + 'static,
{
self.extract_with_ctx(&())
}
fn extract_with_ctx<'a, E, Ctx>(
&'a mut self,
ctx: &'a Ctx,
) -> impl Future<Output = Result<E, E::Rejection>> + Send + 'a
where
E: FromJobCallParts<Ctx> + 'static,
Ctx: Send + Sync,
{
E::from_job_call_parts(self, ctx)
}
}