pub enum Either<A, B> {
Left(A),
Right(B),
}Expand description
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
Extracts the value of an Either over two equal types.
Trait Implementations§
impl<A, B> Copy for Either<A, B>
impl<A, B> Eq for Either<A, B>
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 ClientError
impl From<Either<DecodeError, Error>> for ClientError
Source§impl From<Either<DecodeError, Error>> for WsClientError
impl From<Either<DecodeError, Error>> for WsClientError
Source§impl From<Either<EncodeError, Error>> for ClientError
impl From<Either<EncodeError, Error>> for ClientError
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 (const: unstable) · 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<St, A, B> Responder<St> for Either<A, B>
Combines two different responder types into a single type
impl<St, A, B> Responder<St> 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, st: &St, req: &HttpRequest) -> Response
async fn respond_to(self, st: &St, req: &HttpRequest) -> Response
Builds an HTTP response from this value.
Source§fn with_status(self, status: StatusCode) -> CustomResponder<Self, St>where
Self: Sized,
fn with_status(self, status: StatusCode) -> CustomResponder<Self, St>where
Self: Sized,
Replaces the status code produced by this responder. Read more
Source§fn with_header<K, V>(self, key: K, value: V) -> CustomResponder<Self, St>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, St>where
Self: Sized,
HeaderName: TryFrom<K>,
HeaderValue: TryFrom<V>,
<HeaderName as TryFrom<K>>::Error: Into<HttpError>,
<HeaderValue as TryFrom<V>>::Error: Into<HttpError>,
Sets a header on the response produced by this responder. Read more
Source§impl<A, B, St, Req> Service<St, Req> for Either<A, B>
impl<A, B, St, Req> Service<St, Req> for Either<A, B>
Source§type Error = <A as Service<St, Req>>::Error
type Error = <A as Service<St, Req>>::Error
Error produced while checking readiness or processing a request.
Source§async fn call(
&self,
req: Req,
ctx: Ctx<'_, Either<A, B>, St>,
) -> Result<<Either<A, B> as Service<St, Req>>::Res, <Either<A, B> as Service<St, Req>>::Error>
async fn call( &self, req: Req, ctx: Ctx<'_, Either<A, B>, St>, ) -> Result<<Either<A, B> as Service<St, Req>>::Res, <Either<A, B> as Service<St, Req>>::Error>
Processes a request and asynchronously returns the response. Read more
Source§async fn ready(
&self,
ctx: Ctx<'_, Either<A, B>, St>,
) -> Result<(), <Either<A, B> as Service<St, Req>>::Error>
async fn ready( &self, ctx: Ctx<'_, Either<A, B>, St>, ) -> Result<(), <Either<A, B> as Service<St, Req>>::Error>
Waits until the service is ready to process a request. Read more
Source§fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
fn map<F, Res>(self, f: F) -> ServiceChain<Map<F, Self, Res>, St, Req>
Maps this service’s output to a different type, returning a new service. Read more
Source§fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
fn map_err<F, E>(self, f: F) -> ServiceChain<MapErr<F, Self, E>, St, Req>
Maps this service’s error to a different type, returning a new service. Read more
impl<A, B> StructuralPartialEq for Either<A, B>
Source§impl<St, Err, A, B> WebResponseError<St, Err> for Either<A, B>where
A: WebResponseError<St, Err>,
B: WebResponseError<St, Err>,
impl<St, Err, A, B> WebResponseError<St, Err> for Either<A, B>where
A: WebResponseError<St, Err>,
B: WebResponseError<St, Err>,
Source§fn error_response(&self, st: &St) -> HttpResponse
fn error_response(&self, st: &St) -> HttpResponse
Generate response for error Read more
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> 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§
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,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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
Source§impl<S, St, Req> IntoService<S, St, Req> for Swhere
S: Service<St, Req>,
impl<S, St, Req> IntoService<S, St, Req> for Swhere
S: Service<St, Req>,
Source§fn into_service(self) -> S
fn into_service(self) -> S
Converts this value into a service.