pub struct ServiceChain<S, St, Req> { /* private fields */ }Expand description
A builder for composing services and combinators into one service.
Implementations§
Source§impl<S, St, Req> ServiceChain<S, St, Req>where
S: Service<St, Req>,
impl<S, St, Req> ServiceChain<S, St, Req>where
S: Service<St, Req>,
Sourcepub fn and_then<Next, F>(
self,
service: F,
) -> ServiceChain<AndThen<S, Next>, St, Req>where
ServiceChain<S, St, Req>: Sized,
F: IntoService<Next, St, <S as Service<St, Req>>::Res>,
Next: Service<St, <S as Service<St, Req>>::Res>,
pub fn and_then<Next, F>(
self,
service: F,
) -> ServiceChain<AndThen<S, Next>, St, Req>where
ServiceChain<S, St, Req>: Sized,
F: IntoService<Next, St, <S as Service<St, Req>>::Res>,
Next: Service<St, <S as Service<St, Req>>::Res>,
Calls another service after this service completes successfully.
The current service’s response becomes the next service’s request. If the current service returns an error, the next service is not called.
Sourcepub fn then<Next, F>(self, service: F) -> ServiceChain<Then<S, Next>, St, Req>
pub fn then<Next, F>(self, service: F) -> ServiceChain<Then<S, Next>, St, Req>
Calls another service after this service completes.
The next service receives the current service’s complete Result, so it
can handle either a response or an error.
Sourcepub fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, S, Res>, St, Req>
pub fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, S, Res>, St, Req>
Maps this service’s response to a different type.
This is analogous to Option::map or Result::map.
Sourcepub fn map_err<F, Err>(self, f: F) -> ServiceChain<MapErr<F, S, Err>, St, Req>
pub fn map_err<F, Err>(self, f: F) -> ServiceChain<MapErr<F, S, Err>, St, Req>
Maps this service’s error to a different type.
This is analogous to Result::map_err and is useful for normalizing
error types across composed services.
Sourcepub fn readiness<F>(
self,
ready: F,
) -> ServiceChain<AndThen<S, FnReadiness<F, <S as Service<St, Req>>::Error>>, St, Req>
pub fn readiness<F>( self, ready: F, ) -> ServiceChain<AndThen<S, FnReadiness<F, <S as Service<St, Req>>::Error>>, St, Req>
Adds a custom readiness check to the service chain.
The check runs after the wrapped service’s own readiness check succeeds; the chain is ready only when both are ready.
Sourcepub fn shutdown<F>(
self,
sh: F,
) -> ServiceChain<AndThen<S, FnShutdown<F, <S as Service<St, Req>>::Error>>, St, Req>
pub fn shutdown<F>( self, sh: F, ) -> ServiceChain<AndThen<S, FnShutdown<F, <S as Service<St, Req>>::Error>>, St, Req>
Adds a callback that runs once when the service shuts down.
Sourcepub fn apply_fn<F, In, Out, Err>(
self,
f: F,
) -> ServiceChain<Apply<S, St, Req, F, In, Out, Err>, St, In>
pub fn apply_fn<F, In, Out, Err>( self, f: F, ) -> ServiceChain<Apply<S, St, Req, F, In, Out, Err>, St, In>
Applies an asynchronous function as middleware to this service.
This is shorthand for calling crate::apply_fn on the chained service.
Trait Implementations§
Source§impl<S, St, Req> Clone for ServiceChain<S, St, Req>
impl<S, St, Req> Clone for ServiceChain<S, St, Req>
Source§fn clone(&self) -> ServiceChain<S, St, Req>
fn clone(&self) -> ServiceChain<S, St, Req>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more