[][src]Enum tower::util::Either

pub enum Either<A, B> {
    A(A),
    B(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

A(A)B(B)

Trait Implementations

impl<A, B> Clone for Either<A, B> where
    A: Clone,
    B: Clone
[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<A, B> Debug for Either<A, B> where
    A: Debug,
    B: Debug
[src]

impl<A, B> Future for Either<A, B> where
    A: Future,
    B: Future<Item = <A as Future>::Item>,
    <A as Future>::Error: Into<Box<dyn Error + 'static + Send + Sync>>,
    <B as Future>::Error: Into<Box<dyn Error + 'static + Send + Sync>>, 
[src]

type Item = <A as Future>::Item

The type of value that this future will resolved with if it is successful. Read more

type Error = Box<dyn Error + 'static + Send + Sync>

The type of error that this future will resolve with if it fails in a normal fashion. Read more

fn wait(self) -> Result<Self::Item, Self::Error>[src]

Block the current thread until this future is resolved. Read more

fn map<F, U>(self, f: F) -> Map<Self, F> where
    F: FnOnce(Self::Item) -> U, 
[src]

Map this future's result to a different type, returning a new future of the resulting type. Read more

fn map_err<F, E>(self, f: F) -> MapErr<Self, F> where
    F: FnOnce(Self::Error) -> E, 
[src]

Map this future's error to a different error, returning a new future. Read more

fn from_err<E>(self) -> FromErr<Self, E> where
    E: From<Self::Error>, 
[src]

Map this future's error to any error implementing From for this future's Error, returning a new future. Read more

fn then<F, B>(self, f: F) -> Then<Self, B, F> where
    B: IntoFuture,
    F: FnOnce(Result<Self::Item, Self::Error>) -> B, 
[src]

Chain on a computation for when a future finished, passing the result of the future to the provided closure f. Read more

fn and_then<F, B>(self, f: F) -> AndThen<Self, B, F> where
    B: IntoFuture<Error = Self::Error>,
    F: FnOnce(Self::Item) -> B, 
[src]

Execute another future after this one has resolved successfully. Read more

fn or_else<F, B>(self, f: F) -> OrElse<Self, B, F> where
    B: IntoFuture<Item = Self::Item>,
    F: FnOnce(Self::Error) -> B, 
[src]

Execute another future if this one resolves with an error. Read more

fn select<B>(self, other: B) -> Select<Self, <B as IntoFuture>::Future> where
    B: IntoFuture<Item = Self::Item, Error = Self::Error>, 
[src]

Waits for either one of two futures to complete. Read more

fn select2<B>(self, other: B) -> Select2<Self, <B as IntoFuture>::Future> where
    B: IntoFuture
[src]

Waits for either one of two differently-typed futures to complete. Read more

fn join<B>(self, other: B) -> Join<Self, <B as IntoFuture>::Future> where
    B: IntoFuture<Error = Self::Error>, 
[src]

Joins the result of two futures, waiting for them both to complete. Read more

fn join3<B, C>(
    self,
    b: B,
    c: C
) -> Join3<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future> where
    B: IntoFuture<Error = Self::Error>,
    C: IntoFuture<Error = Self::Error>, 
[src]

Same as join, but with more futures.

fn join4<B, C, D>(
    self,
    b: B,
    c: C,
    d: D
) -> Join4<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future> where
    B: IntoFuture<Error = Self::Error>,
    C: IntoFuture<Error = Self::Error>,
    D: IntoFuture<Error = Self::Error>, 
[src]

Same as join, but with more futures.

fn join5<B, C, D, E>(
    self,
    b: B,
    c: C,
    d: D,
    e: E
) -> Join5<Self, <B as IntoFuture>::Future, <C as IntoFuture>::Future, <D as IntoFuture>::Future, <E as IntoFuture>::Future> where
    B: IntoFuture<Error = Self::Error>,
    C: IntoFuture<Error = Self::Error>,
    D: IntoFuture<Error = Self::Error>,
    E: IntoFuture<Error = Self::Error>, 
[src]

Same as join, but with more futures.

fn into_stream(self) -> IntoStream<Self>[src]

Convert this future into a single element stream. Read more

fn flatten(self) -> Flatten<Self> where
    Self::Item: IntoFuture,
    <Self::Item as IntoFuture>::Error: From<Self::Error>, 
[src]

Flatten the execution of this future when the successful result of this future is itself another future. Read more

fn flatten_stream(self) -> FlattenStream<Self> where
    Self::Item: Stream,
    <Self::Item as Stream>::Error == Self::Error
[src]

Flatten the execution of this future when the successful result of this future is a stream. Read more

fn fuse(self) -> Fuse<Self>[src]

Fuse a future such that poll will never again be called once it has completed. Read more

fn inspect<F>(self, f: F) -> Inspect<Self, F> where
    F: FnOnce(&Self::Item), 
[src]

Do something with the item of a future, passing it on. Read more

fn catch_unwind(self) -> CatchUnwind<Self> where
    Self: UnwindSafe
[src]

Catches unwinding panics while polling the future. Read more

fn shared(self) -> Shared<Self>[src]

Create a cloneable handle to this future where all handles will resolve to the same result. Read more

impl<A, B, Request> Service<Request> for Either<A, B> where
    A: Service<Request>,
    B: Service<Request, Response = <A as Service<Request>>::Response>,
    <A as Service<Request>>::Error: Into<Box<dyn Error + 'static + Send + Sync>>,
    <B as Service<Request>>::Error: Into<Box<dyn Error + 'static + Send + Sync>>, 
[src]

type Response = <A as Service<Request>>::Response

Responses given by the service.

type Error = Box<dyn Error + 'static + Send + Sync>

Errors produced by the service.

type Future = Either<<A as Service<Request>>::Future, <B as Service<Request>>::Future>

The future response value.

Auto Trait Implementations

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

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

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

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

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

Blanket Implementations

impl<T, Request> ServiceExt<Request> for T where
    T: Service<Request> + ?Sized
[src]

fn ready(self) -> Ready<Self, Request> where
    Self: Sized
[src]

A future yielding the service when it is ready to accept a request.

fn oneshot(self, req: Request) -> Oneshot<Self, Request> where
    Self: Sized
[src]

Consume this Service, calling with the providing request once it is ready.

fn call_all<S>(self, reqs: S) -> CallAll<Self, S> where
    Self: Sized,
    Self::Error: Into<Box<dyn Error + Send + Sync>>,
    S: Stream<Item = Request>,
    S::Error: Into<Box<dyn Error + Send + Sync>>, 
[src]

Process all requests from the given Stream, and produce a Stream of their responses. Read more

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<F> IntoFuture for F where
    F: Future
[src]

type Future = F

The future that this type can be converted into.

type Item = <F as Future>::Item

The item that the future may resolve with.

type Error = <F as Future>::Error

The error that the future may resolve with.

impl<C, Target> MakeConnection<Target> for C where
    C: Service<Target>,
    <C as Service<Target>>::Response: AsyncRead,
    <C as Service<Target>>::Response: AsyncWrite
[src]

type Connection = <C as Service<Target>>::Response

The transport provided by this service

type Error = <C as Service<Target>>::Error

Errors produced by the connecting service

type Future = <C as Service<Target>>::Future

The future that eventually produces the transport

impl<M, S, Target, Request> MakeService<Target, Request> for M where
    M: Service<Target, Response = S>,
    S: Service<Request>, 
[src]

type Response = <S as Service<Request>>::Response

Responses given by the service

type Error = <S as Service<Request>>::Error

Errors produced by the service

type Service = S

The Service value created by this factory

type MakeError = <M as Service<Target>>::Error

Errors produced while building a service.

type Future = <M as Service<Target>>::Future

The future of the Service instance.