pub struct ServiceChain<S, St, Req> { /* private fields */ }Expand description
A builder for composing services and combinators into one service.
Implementations§
Source§impl<S: Service<St, Req>, St, Req> ServiceChain<S, St, Req>
impl<S: Service<St, Req>, St, Req> ServiceChain<S, St, Req>
Sourcepub fn and_then<Next, F>(
self,
service: F,
) -> ServiceChain<AndThen<S, Next>, St, Req>
pub fn and_then<Next, F>( self, service: F, ) -> ServiceChain<AndThen<S, Next>, St, Req>
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::Error>>, St, Req>
pub fn readiness<F>( self, ready: F, ) -> ServiceChain<AndThen<S, FnReadiness<F, S::Error>>, St, Req>
Adds a custom readiness check to the service chain.
Sourcepub fn shutdown<F>(
self,
sh: F,
) -> ServiceChain<AndThen<S, FnShutdown<F, S::Error>>, St, Req>
pub fn shutdown<F>( self, sh: F, ) -> ServiceChain<AndThen<S, FnShutdown<F, S::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.