pub struct Ctx<'a, Svc, St = ()>where
Svc: ?Sized,{ /* private fields */ }Expand description
Context provided to Service lifecycle methods.
A context gives a service access to pipeline state and coordinates calls to inner services with the pipeline’s readiness and shutdown machinery.
Implementations§
Source§impl<'a, Svc, St> Ctx<'a, Svc, St>
impl<'a, Svc, St> Ctx<'a, Svc, St>
Sourcepub async fn ready<S, Req>(
&self,
svc: &'a S,
) -> Result<(), <S as Service<St, Req>>::Error>where
S: Service<St, Req>,
pub async fn ready<S, Req>(
&self,
svc: &'a S,
) -> Result<(), <S as Service<St, Req>>::Error>where
S: Service<St, Req>,
Waits until svc is ready to process a request.
Sourcepub async fn call<S, Req>(
&self,
svc: &'a S,
req: Req,
) -> Result<<S as Service<St, Req>>::Res, <S as Service<St, Req>>::Error>where
S: Service<St, Req>,
pub async fn call<S, Req>(
&self,
svc: &'a S,
req: Req,
) -> Result<<S as Service<St, Req>>::Res, <S as Service<St, Req>>::Error>where
S: Service<St, Req>,
Waits for svc to become ready, then calls it.
Sourcepub async fn call_nowait<S, Req>(
&self,
svc: &'a S,
req: Req,
) -> Result<<S as Service<St, Req>>::Res, <S as Service<St, Req>>::Error>where
S: Service<St, Req>,
pub async fn call_nowait<S, Req>(
&self,
svc: &'a S,
req: Req,
) -> Result<<S as Service<St, Req>>::Res, <S as Service<St, Req>>::Error>where
S: Service<St, Req>,
Calls svc without checking readiness.
The caller must ensure that svc is ready.
Sourcepub async fn poll_fn<F, R>(&'a self, f: F) -> R
pub async fn poll_fn<F, R>(&'a self, f: F) -> R
Polls a closure until completion using the dispatcher’s task Context.
The Context uses the waker of the task that currently owns the readiness
check. Outside of a readiness check a no-op waker is used, so a Pending
result is not woken. If the current owner is not the main runner, the main
runner is also scheduled for wake-up.
Sourcepub fn poll_once<F, R>(&'a self, f: F) -> R
pub fn poll_once<F, R>(&'a self, f: F) -> R
Calls a closure once with the dispatcher’s task Context.
The Context uses the waker of the task that currently owns the readiness
check. Outside of a readiness check a no-op waker is used, so a Pending
result is not woken. If the current owner is not the main runner, the main
runner is also scheduled for wake-up.