pub enum Either<A, B> {
Left(A),
Right(B),
}
Expand description
Combines two different futures, streams, or sinks having the same associated types into a single type.
Variants§
Implementations§
Source§impl<T> Either<T, T>
impl<T> Either<T, T>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Extract the value of an either over two equivalent types.
Trait Implementations§
Source§impl<A, B> Error for Either<A, B>
Either
implements Error
if both A
and B
implement it.
impl<A, B> Error for Either<A, B>
Either
implements Error
if both A
and B
implement it.
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<Either<DecodeError, Error>> for SendRequestError
impl From<Either<DecodeError, Error>> for SendRequestError
Source§impl From<Either<DecodeError, Error>> for WsClientError
impl From<Either<DecodeError, Error>> for WsClientError
Source§impl From<Either<EncodeError, Error>> for SendRequestError
impl From<Either<EncodeError, Error>> for SendRequestError
Source§impl From<Either<EncodeError, Error>> for WsClientError
impl From<Either<EncodeError, Error>> for WsClientError
Source§impl From<Either<PayloadError, Error>> for PayloadError
impl From<Either<PayloadError, Error>> for PayloadError
Source§impl<A, B> Ord for Either<A, B>
impl<A, B> Ord for Either<A, B>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<A, B> PartialOrd for Either<A, B>where
A: PartialOrd,
B: PartialOrd,
impl<A, B> PartialOrd for Either<A, B>where
A: PartialOrd,
B: PartialOrd,
Source§impl<A, B, Err> Responder<Err> for Either<A, B>
Combines two different responder types into a single type
impl<A, B, Err> Responder<Err> for Either<A, B>
Combines two different responder types into a single type
use ntex::{web::HttpResponse, util::Either};
fn index() -> Either<HttpResponse, &'static str> {
if is_a_variant() {
// <- choose left variant
Either::Left(HttpResponse::BadRequest().body("Bad data"))
} else {
// <- Right variant
Either::Right("Hello!")
}
}
Source§async fn respond_to(self, req: &HttpRequest) -> Response
async fn respond_to(self, req: &HttpRequest) -> Response
Convert itself to http response.
Source§fn with_status(self, status: StatusCode) -> CustomResponder<Self, Err>where
Self: Sized,
fn with_status(self, status: StatusCode) -> CustomResponder<Self, Err>where
Self: Sized,
Override a status code for a Responder. Read more
Source§fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self, Err>where
Self: Sized,
HeaderName: TryFrom<K>,
HeaderValue: TryFrom<V>,
<HeaderName as TryFrom<K>>::Error: Into<HttpError>,
<HeaderValue as TryFrom<V>>::Error: Into<HttpError>,
fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self, Err>where
Self: Sized,
HeaderName: TryFrom<K>,
HeaderValue: TryFrom<V>,
<HeaderName as TryFrom<K>>::Error: Into<HttpError>,
<HeaderValue as TryFrom<V>>::Error: Into<HttpError>,
Add header to the Responder’s response. Read more
Source§impl<A, B, Err> WebResponseError<Err> for Either<A, B>
impl<A, B, Err> WebResponseError<Err> for Either<A, B>
Source§fn status_code(&self) -> StatusCode
fn status_code(&self) -> StatusCode
Response’s status code Read more
Source§fn error_response(&self, req: &HttpRequest) -> HttpResponse
fn error_response(&self, req: &HttpRequest) -> HttpResponse
Generate response for error Read more
impl<A, B> Copy for Either<A, B>
impl<A, B> Eq for Either<A, B>
impl<A, B> StructuralPartialEq for Either<A, B>
Auto Trait Implementations§
impl<A, B> Freeze for Either<A, B>
impl<A, B> RefUnwindSafe for Either<A, B>where
A: RefUnwindSafe,
B: RefUnwindSafe,
impl<A, B> Send for Either<A, B>
impl<A, B> Sync for Either<A, B>
impl<A, B> Unpin for Either<A, B>
impl<A, B> UnwindSafe for Either<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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more