Struct ntex_service::Pipeline
source · [−]pub struct Pipeline<T, R> { /* private fields */ }Expand description
Pipeline service - pipeline allows to compose multiple service into one service.
Implementations
sourceimpl<T: Service<R>, R> Pipeline<T, R>
impl<T: Service<R>, R> Pipeline<T, R>
sourcepub fn and_then<F, U>(self, service: F) -> Pipeline<AndThen<T, U, R>, R> where
Self: Sized,
F: IntoService<U, T::Response>,
U: Service<T::Response, Error = T::Error>,
pub fn and_then<F, U>(self, service: F) -> Pipeline<AndThen<T, U, R>, R> where
Self: Sized,
F: IntoService<U, T::Response>,
U: Service<T::Response, Error = T::Error>,
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<F, U>(self, service: F) -> Pipeline<Then<T, U, R>, R> where
Self: Sized,
F: IntoService<U, Result<T::Response, T::Error>>,
U: Service<Result<T::Response, T::Error>, Error = T::Error>,
pub fn then<F, U>(self, service: F) -> Pipeline<Then<T, U, R>, R> where
Self: Sized,
F: IntoService<U, Result<T::Response, T::Error>>,
U: Service<Result<T::Response, T::Error>, Error = T::Error>,
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 pipeline and returns a wrapped version of it.
sourcepub fn map<F, Res>(self, f: F) -> Pipeline<Map<T, F, R, Res>, R> where
Self: Sized,
F: FnMut(T::Response) -> Res,
pub fn map<F, Res>(self, f: F) -> Pipeline<Map<T, F, R, Res>, R> where
Self: Sized,
F: FnMut(T::Response) -> Res,
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.
Note that this function consumes the receiving service and returns a
wrapped version of it, similar to the existing map methods in the
standard library.
sourcepub fn map_err<F, E>(self, f: F) -> Pipeline<MapErr<T, R, F, E>, R> where
Self: Sized,
F: Fn(T::Error) -> E,
pub fn map_err<F, E>(self, f: F) -> Pipeline<MapErr<T, R, F, E>, R> where
Self: Sized,
F: Fn(T::Error) -> E,
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.
Note that this function consumes the receiving service and returns a wrapped version of it.
Trait Implementations
sourceimpl<T: Service<R>, R> Service<R> for Pipeline<T, R>
impl<T: Service<R>, R> Service<R> for Pipeline<T, R>
sourcefn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), T::Error>>
fn poll_ready(&self, cx: &mut Context<'_>) -> Poll<Result<(), T::Error>>
Returns Ready when the service is able to process requests. Read more
sourcefn poll_shutdown(&self, cx: &mut Context<'_>, is_error: bool) -> Poll<()>
fn poll_shutdown(&self, cx: &mut Context<'_>, is_error: bool) -> Poll<()>
Shutdown service. Read more
sourcefn call(&self, req: R) -> Self::Future
fn call(&self, req: R) -> Self::Future
Process the request and return the response asynchronously. Read more
Auto Trait Implementations
impl<T, R> RefUnwindSafe for Pipeline<T, R> where
R: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, R> Send for Pipeline<T, R> where
R: Send,
T: Send,
impl<T, R> Sync for Pipeline<T, R> where
R: Sync,
T: Sync,
impl<T, R> Unpin for Pipeline<T, R> where
R: Unpin,
T: Unpin,
impl<T, R> UnwindSafe for Pipeline<T, R> where
R: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T, Req> IntoService<T, Req> for T where
T: Service<Req>,
impl<T, Req> IntoService<T, Req> for T where
T: Service<Req>,
sourcefn into_service(self) -> T
fn into_service(self) -> T
Convert to a Service