[][src]Enum actix_web::Either

pub enum Either<A, B> {
    A(A),
    B(B),
}

Combines two different responder types into a single type

use actix_web::{Either, Error, HttpResponse};

type RegisterResult = Either<HttpResponse, Result<HttpResponse, Error>>;

fn index() -> RegisterResult {
    if is_a_variant() {
        // <- choose left variant
        Either::A(HttpResponse::BadRequest().body("Bad data"))
    } else {
        Either::B(
            // <- Right variant
            Ok(HttpResponse::Ok()
                .content_type("text/html")
                .body("Hello!"))
        )
    }
}

Variants

A(A)

First branch of the type

B(B)

Second branch of the type

Trait Implementations

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

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

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

type Error = Error

The associated error which can be returned.

type Future = EitherResponder<A, B>

The future response value.

impl<A, B> StructuralPartialEq for Either<A, B>[src]

Auto Trait Implementations

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> UnwindSafe for Either<A, B> where
    A: UnwindSafe,
    B: UnwindSafe

Blanket Implementations

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

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

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

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

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

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Sealed<T> for T where
    T: ?Sized

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<V, T> VZip<V> for T where
    V: MultiLane<T>,