pub struct ServiceChainFactory<T, Req, C = ()> { /* private fields */ }Expand description
Service factory builder
Implementations§
Source§impl<T, Req, C> ServiceChainFactory<T, Req, C>where
T: ServiceFactory<Req, C>,
impl<T, Req, C> ServiceChainFactory<T, Req, C>where
T: ServiceFactory<Req, C>,
Sourcepub fn and_then<F, U>(
self,
factory: F,
) -> ServiceChainFactory<AndThenFactory<T, U>, Req, C>where
ServiceChainFactory<T, Req, C>: Sized,
F: IntoServiceFactory<U, <T as ServiceFactory<Req, C>>::Response, C>,
U: ServiceFactory<<T as ServiceFactory<Req, C>>::Response, C, Error = <T as ServiceFactory<Req, C>>::Error, InitError = <T as ServiceFactory<Req, C>>::InitError>,
pub fn and_then<F, U>(
self,
factory: F,
) -> ServiceChainFactory<AndThenFactory<T, U>, Req, C>where
ServiceChainFactory<T, Req, C>: Sized,
F: IntoServiceFactory<U, <T as ServiceFactory<Req, C>>::Response, C>,
U: ServiceFactory<<T as ServiceFactory<Req, C>>::Response, C, Error = <T as ServiceFactory<Req, C>>::Error, InitError = <T as ServiceFactory<Req, C>>::InitError>,
Call another service after call to this one has resolved successfully.
Sourcepub fn apply<U>(
self,
tr: U,
) -> ServiceChainFactory<ApplyMiddleware<U, T, C>, Req, C>
pub fn apply<U>( self, tr: U, ) -> ServiceChainFactory<ApplyMiddleware<U, T, C>, Req, C>
Apply middleware to current service factory.
Short version of apply(middleware, chain_factory(...))
Sourcepub fn apply_fn<F, R, In, Out, Err>(
self,
f: F,
) -> ServiceChainFactory<ApplyFactory<T, Req, C, F, R, In, Out, Err>, In, C>where
F: Fn(In, Pipeline<<T as ServiceFactory<Req, C>>::Service>) -> R + Clone,
R: Future<Output = Result<Out, Err>>,
T: ServiceFactory<Req, C>,
Err: From<<T as ServiceFactory<Req, C>>::Error>,
pub fn apply_fn<F, R, In, Out, Err>(
self,
f: F,
) -> ServiceChainFactory<ApplyFactory<T, Req, C, F, R, In, Out, Err>, In, C>where
F: Fn(In, Pipeline<<T as ServiceFactory<Req, C>>::Service>) -> R + Clone,
R: Future<Output = Result<Out, Err>>,
T: ServiceFactory<Req, C>,
Err: From<<T as ServiceFactory<Req, C>>::Error>,
Apply function middleware to current service factory.
Short version of apply_fn_factory(chain_factory(...), fn)
Sourcepub fn then<F, U>(
self,
factory: F,
) -> ServiceChainFactory<ThenFactory<T, U>, Req, C>where
ServiceChainFactory<T, Req, C>: Sized,
C: Clone,
F: IntoServiceFactory<U, Result<<T as ServiceFactory<Req, C>>::Response, <T as ServiceFactory<Req, C>>::Error>, C>,
U: ServiceFactory<Result<<T as ServiceFactory<Req, C>>::Response, <T as ServiceFactory<Req, C>>::Error>, C, Error = <T as ServiceFactory<Req, C>>::Error, InitError = <T as ServiceFactory<Req, C>>::InitError>,
pub fn then<F, U>(
self,
factory: F,
) -> ServiceChainFactory<ThenFactory<T, U>, Req, C>where
ServiceChainFactory<T, Req, C>: Sized,
C: Clone,
F: IntoServiceFactory<U, Result<<T as ServiceFactory<Req, C>>::Response, <T as ServiceFactory<Req, C>>::Error>, C>,
U: ServiceFactory<Result<<T as ServiceFactory<Req, C>>::Response, <T as ServiceFactory<Req, C>>::Error>, C, Error = <T as ServiceFactory<Req, C>>::Error, InitError = <T as ServiceFactory<Req, C>>::InitError>,
Create chain factory to chain on a computation for when a call to the
service finished, passing the result of the call to the next
service U.
Note that this function consumes the receiving factory and returns a wrapped version of it.
Sourcepub fn map<F, Res>(
self,
f: F,
) -> ServiceChainFactory<MapFactory<T, F, Req, Res, C>, Req, C>where
ServiceChainFactory<T, Req, C>: Sized,
F: Fn(<T as ServiceFactory<Req, C>>::Response) -> Res + Clone,
pub fn map<F, Res>(
self,
f: F,
) -> ServiceChainFactory<MapFactory<T, F, Req, Res, C>, Req, C>where
ServiceChainFactory<T, Req, C>: Sized,
F: Fn(<T as ServiceFactory<Req, C>>::Response) -> Res + Clone,
Map this service’s output to a different type, returning a new service of the resulting type.
Sourcepub fn map_err<F, E>(
self,
f: F,
) -> ServiceChainFactory<MapErrFactory<T, Req, C, F, E>, Req, C>where
ServiceChainFactory<T, Req, C>: Sized,
F: Fn(<T as ServiceFactory<Req, C>>::Error) -> E + Clone,
pub fn map_err<F, E>(
self,
f: F,
) -> ServiceChainFactory<MapErrFactory<T, Req, C, F, E>, Req, C>where
ServiceChainFactory<T, Req, C>: Sized,
F: Fn(<T as ServiceFactory<Req, C>>::Error) -> E + Clone,
Map this service’s error to a different error.
Sourcepub fn map_init_err<F, E>(
self,
f: F,
) -> ServiceChainFactory<MapInitErr<T, Req, C, F, E>, Req, C>where
ServiceChainFactory<T, Req, C>: Sized,
F: Fn(<T as ServiceFactory<Req, C>>::InitError) -> E + Clone,
pub fn map_init_err<F, E>(
self,
f: F,
) -> ServiceChainFactory<MapInitErr<T, Req, C, F, E>, Req, C>where
ServiceChainFactory<T, Req, C>: Sized,
F: Fn(<T as ServiceFactory<Req, C>>::InitError) -> E + Clone,
Map this factory’s init error to a different error, returning a new factory.
Sourcepub async fn pipeline(
&self,
cfg: C,
) -> Result<Pipeline<<T as ServiceFactory<Req, C>>::Service>, <T as ServiceFactory<Req, C>>::InitError>where
ServiceChainFactory<T, Req, C>: Sized,
pub async fn pipeline(
&self,
cfg: C,
) -> Result<Pipeline<<T as ServiceFactory<Req, C>>::Service>, <T as ServiceFactory<Req, C>>::InitError>where
ServiceChainFactory<T, Req, C>: Sized,
Create and return a new service value asynchronously and wrap into a container
Trait Implementations§
Source§impl<T, R, C> Clone for ServiceChainFactory<T, R, C>where
T: Clone,
impl<T, R, C> Clone for ServiceChainFactory<T, R, C>where
T: Clone,
Source§fn clone(&self) -> ServiceChainFactory<T, R, C>
fn clone(&self) -> ServiceChainFactory<T, R, C>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<T, R, C> Debug for ServiceChainFactory<T, R, C>where
T: Debug,
impl<T, R, C> Debug for ServiceChainFactory<T, R, C>where
T: Debug,
Source§impl<T, R, C> ServiceFactory<R, C> for ServiceChainFactory<T, R, C>where
T: ServiceFactory<R, C>,
impl<T, R, C> ServiceFactory<R, C> for ServiceChainFactory<T, R, C>where
T: ServiceFactory<R, C>,
Source§type Response = <T as ServiceFactory<R, C>>::Response
type Response = <T as ServiceFactory<R, C>>::Response
Source§type Error = <T as ServiceFactory<R, C>>::Error
type Error = <T as ServiceFactory<R, C>>::Error
Source§type Service = <T as ServiceFactory<R, C>>::Service
type Service = <T as ServiceFactory<R, C>>::Service
Service created by this factory.Source§type InitError = <T as ServiceFactory<R, C>>::InitError
type InitError = <T as ServiceFactory<R, C>>::InitError
Source§async fn create(
&self,
cfg: C,
) -> Result<<ServiceChainFactory<T, R, C> as ServiceFactory<R, C>>::Service, <ServiceChainFactory<T, R, C> as ServiceFactory<R, C>>::InitError>
async fn create( &self, cfg: C, ) -> Result<<ServiceChainFactory<T, R, C> as ServiceFactory<R, C>>::Service, <ServiceChainFactory<T, R, C> as ServiceFactory<R, C>>::InitError>
Source§async fn pipeline(
&self,
cfg: Cfg,
) -> Result<Pipeline<Self::Service>, Self::InitError>where
Self: Sized,
async fn pipeline(
&self,
cfg: Cfg,
) -> Result<Pipeline<Self::Service>, Self::InitError>where
Self: Sized,
Source§fn map<F, Res>(
self,
f: F,
) -> ServiceChainFactory<MapFactory<Self, F, Req, Res, Cfg>, Req, Cfg>
fn map<F, Res>( self, f: F, ) -> ServiceChainFactory<MapFactory<Self, F, Req, Res, Cfg>, Req, Cfg>
Source§fn map_err<F, E>(
self,
f: F,
) -> ServiceChainFactory<MapErrFactory<Self, Req, Cfg, F, E>, Req, Cfg>
fn map_err<F, E>( self, f: F, ) -> ServiceChainFactory<MapErrFactory<Self, Req, Cfg, F, E>, Req, Cfg>
Source§fn map_init_err<F, E>(
self,
f: F,
) -> ServiceChainFactory<MapInitErr<Self, Req, Cfg, F, E>, Req, Cfg>
fn map_init_err<F, E>( self, f: F, ) -> ServiceChainFactory<MapInitErr<Self, Req, Cfg, F, E>, Req, Cfg>
Auto Trait Implementations§
impl<T, Req, C> Freeze for ServiceChainFactory<T, Req, C>where
T: Freeze,
impl<T, Req, C> RefUnwindSafe for ServiceChainFactory<T, Req, C>
impl<T, Req, C> Send for ServiceChainFactory<T, Req, C>
impl<T, Req, C> Sync for ServiceChainFactory<T, Req, C>
impl<T, Req, C> Unpin for ServiceChainFactory<T, Req, C>
impl<T, Req, C> UnwindSafe for ServiceChainFactory<T, Req, C>
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<T, Req, Cfg> IntoServiceFactory<T, Req, Cfg> for Twhere
T: ServiceFactory<Req, Cfg>,
impl<T, Req, Cfg> IntoServiceFactory<T, Req, Cfg> for Twhere
T: ServiceFactory<Req, Cfg>,
Source§fn into_factory(self) -> T
fn into_factory(self) -> T
Self to a ServiceFactory