Enum Either

pub enum Either<A, B>

Combine two different service types into a single type.

Both services must be of the same request, response, and error types. Either is useful for handling conditional branching in service middleware to different inner service types.

Variants

Left(A)
Right(B)

Trait Implementations

impl<A, B, Request> Service<Request> for Either<A, B> where A: Service<Request>, B: Service<Request, Response = A::Response, Error = A::Error>,

type Response = <A as Service<Request>>::Response;
type Error = <A as Service<Request>>::Error;
type Future = EitherResponseFuture<<A as Service<Request>>::Future, <B as Service<Request>>::Future>;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>
fn call(&mut self, request: Request) -> Self::Future

impl<A: Clone, B: Clone> Clone for Either<A, B>

fn clone(&self) -> Self

impl<A: Copy, B: Copy> Copy for Either<A, B>

impl<A: Debug, B: Debug> Debug for Either<A, B>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<S, A, B> Layer<S> for Either<A, B> where A: Layer<S>, B: Layer<S>,

type Service = Either<<A as Layer<S>>::Service, <B as Layer<S>>::Service>;
fn layer(&self, inner: S) -> Self::Service

Auto Trait Implementations

impl<A, B> Freeze for Either<A, B> where A: Freeze, B: Freeze,

impl<A, B> RefUnwindSafe for Either<A, B> where A: RefUnwindSafe, B: RefUnwindSafe,

impl<A, B> Send for Either<A, B> where A: Send, B: Send,

impl<A, B> Sync for Either<A, B> where A: Sync, B: Sync,

impl<A, B> Unpin for Either<A, B> where A: Unpin, B: Unpin,

impl<A, B> UnsafeUnpin for Either<A, B> where A: UnsafeUnpin, B: UnsafeUnpin,

impl<A, B> UnwindSafe for Either<A, B> where A: UnwindSafe, B: UnwindSafe,

Blanket Implementations

impl<C, Target> MakeConnection<Target> for Either<A, B> where C: Service<Target>, <C as Service<Target>>::Response: AsyncRead + AsyncWrite,

type Connection = <C as Service<Target>>::Response;
type Error = <C as Service<Target>>::Error;
type Future = <C as Service<Target>>::Future;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), <C as MakeConnection<Target>>::Error>>
fn make_connection(&mut self, target: Target) -> <C as MakeConnection<Target>>::Future

impl<M, S, Target, Request> MakeService<Target, Request> for Either<A, B> where M: Service<Target, Response = S>, S: Service<Request>,

type Response = <S as Service<Request>>::Response;
type Error = <S as Service<Request>>::Error;
type Service = S;
type MakeError = <M as Service<Target>>::Error;
type Future = <M as Service<Target>>::Future;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>
fn make_service(&mut self, target: Target) -> <M as MakeService<Target, Request>>::Future

impl<T> Any for Either<A, B> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Either<A, B> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Either<A, B> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Either<A, B> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Either<A, B>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Instrument for Either<A, B>

impl<T> ToOwned for Either<A, B> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> WithSubscriber for Either<A, B>

impl<T, Request> ServiceExt<Request> for Either<A, B> where T: Service<Request> + ?Sized,

impl<T, U> Into<U> for Either<A, B> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Either<A, B> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Either<A, B> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>