pub struct ServiceChain<S, St, Req> { /* private fields */ }Expand description
Chain builder - chain allows to compose multiple service 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>
Call another service after call to this one has resolved successfully.
This function can be used to chain two services together and ensure that the second service isn’t called until call to the fist service have finished. Result of the call to the first service is used as an input parameter for the second service’s call.
Note that this function consumes the receiving service and returns a wrapped version of it.
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>
Chain on a computation for when a call to the service finished,
passing the result of the call to the next service U.
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>
Map this service’s output to a different type, returning a new service of the resulting type.
This function is similar to the Option::map or Iterator::map where
it will change the type of the underlying service.
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>
Map this service’s error to a different error, returning a new service.
This function is similar to the Result::map_err where it will change
the error type of the underlying service. This is useful for example to
ensure that services have the same error type.
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>
Add 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>
Add custom readiness check to the service chain.
Trait Implementations§
Source§impl<S, St, Req> Clone for ServiceChain<S, St, Req>
impl<S, St, Req> Clone for ServiceChain<S, St, Req>
Source§impl<S, St, Req> Debug for ServiceChain<S, St, Req>
impl<S, St, Req> Debug for ServiceChain<S, St, Req>
Source§impl<S: Service<St, Req>, St, Req> Service<St, Req> for ServiceChain<S, St, Req>
impl<S: Service<St, Req>, St, Req> Service<St, Req> for ServiceChain<S, St, Req>
Source§type Error = <S as Service<St, Req>>::Error
type Error = <S as Service<St, Req>>::Error
Source§async fn call(
&self,
req: Req,
ctx: Ctx<'_, Self, St>,
) -> Result<Self::Res, Self::Error>
async fn call( &self, req: Req, ctx: Ctx<'_, Self, St>, ) -> Result<Self::Res, Self::Error>
Source§async fn ready(&self, ctx: Ctx<'_, Self, St>) -> Result<(), Self::Error>
async fn ready(&self, ctx: Ctx<'_, Self, St>) -> Result<(), Self::Error>
Source§fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
Source§fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
Auto Trait Implementations§
impl<S, St, Req> Freeze for ServiceChain<S, St, Req>
impl<S, St, Req> RefUnwindSafe for ServiceChain<S, St, Req>
impl<S, St, Req> Send for ServiceChain<S, St, Req>
impl<S, St, Req> Sync for ServiceChain<S, St, Req>
impl<S, St, Req> Unpin for ServiceChain<S, St, Req>
impl<S, St, Req> UnsafeUnpin for ServiceChain<S, St, Req>
impl<S, St, Req> UnwindSafe for ServiceChain<S, St, Req>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S, St, Req> IntoService<S, St, Req> for Swhere
S: Service<St, Req>,
impl<S, St, Req> IntoService<S, St, Req> for Swhere
S: Service<St, Req>,
Source§fn into_service(self) -> S
fn into_service(self) -> S
Service