Enum actix_web::body::EitherBody [−][src]
pub enum EitherBody<L, R = BoxBody> {
Left {
body: L,
},
Right {
body: R,
},
}Expand description
An “either” type specialized for body types.
It is common, in middleware especially, to conditionally return an inner service’s unknown/
generic body B type or return early with a new response. This type’s “right” variant
defaults to BoxBody since error responses are the common case.
For example, middleware will often have type Response = ServiceResponse<EitherBody<B>>.
This means that the inner service’s response body type maps to the Left variant and the
middleware’s own error responses use the default Right variant of BoxBody. Of course,
there’s no reason it couldn’t use EitherBody<B, String> instead if its alternative
responses have a known type.
Variants
Left
A body of type L.
Right
A body of type R.
Implementations
Creates new EitherBody left variant with a boxed right variant.
If the expected R type will be inferred and is not BoxBody then use the
left constructor instead.
Creates new EitherBody using left variant.
Creates new EitherBody using right variant.
Trait Implementations
impl<L, R> MessageBody for EitherBody<L, R> where
L: 'static + MessageBody,
R: 'static + MessageBody,
impl<L, R> MessageBody for EitherBody<L, R> where
L: 'static + MessageBody,
R: 'static + MessageBody,
pub fn poll_next(
self: Pin<&mut EitherBody<L, R>>,
cx: &mut Context<'_>
) -> Poll<Option<Result<Bytes, <EitherBody<L, R> as MessageBody>::Error>>>
pub fn poll_next(
self: Pin<&mut EitherBody<L, R>>,
cx: &mut Context<'_>
) -> Poll<Option<Result<Bytes, <EitherBody<L, R> as MessageBody>::Error>>>
Attempt to pull out the next chunk of body bytes. Read more
Try to convert into the complete chunk of body bytes. Read more
Auto Trait Implementations
impl<L, R> RefUnwindSafe for EitherBody<L, R> where
L: RefUnwindSafe,
R: RefUnwindSafe,
impl<L, R> Send for EitherBody<L, R> where
L: Send,
R: Send,
impl<L, R> Sync for EitherBody<L, R> where
L: Sync,
R: Sync,
impl<L, R> UnwindSafe for EitherBody<L, R> where
L: UnwindSafe,
R: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more
