pub struct EitherService<A, B> { /* private fields */ }Expand description
Combine two different service types into a single type.
Both services must be of the same request, response, and error types.
EitherService is useful for handling conditional branching in service
middleware to different inner service types.
Trait Implementations§
Source§impl<A, B> Service for EitherService<A, B>
impl<A, B> Service for EitherService<A, B>
Source§type Request = Either<<A as Service>::Request, <B as Service>::Request>
type Request = Either<<A as Service>::Request, <B as Service>::Request>
Requests handled by the service.
Source§type Future = Either<<A as Service>::Future, <B as Service>::Future>
type Future = Either<<A as Service>::Future, <B as Service>::Future>
The future response value.
Source§fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
Returns
Ready when the service is able to process requests. Read moreSource§fn call(&mut self, req: Either<A::Request, B::Request>) -> Self::Future
fn call(&mut self, req: Either<A::Request, B::Request>) -> Self::Future
Process the request and return the response asynchronously. Read more
Auto Trait Implementations§
impl<A, B> Freeze for EitherService<A, B>
impl<A, B> RefUnwindSafe for EitherService<A, B>where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Send for EitherService<A, B>
impl<A, B> Sync for EitherService<A, B>
impl<A, B> Unpin for EitherService<A, B>
impl<A, B> UnwindSafe for EitherService<A, B>where
A: UnwindSafe,
B: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoService<T> for Twhere
T: Service,
impl<T> IntoService<T> for Twhere
T: Service,
Source§fn into_service(self) -> T
fn into_service(self) -> T
Convert to a
Service