pub enum ResponseBody<B> {
Body(B),
Other(Body),
}Expand description
Response body preserving either a concrete body type or a type-erased body.
Variants§
Implementations§
Source§impl ResponseBody<Body>
impl ResponseBody<Body>
Sourcepub fn into_body<B>(self) -> ResponseBody<B>
pub fn into_body<B>(self) -> ResponseBody<B>
Converts a type-erased response body to another concrete response type.
Source§impl<B> ResponseBody<B>
impl<B> ResponseBody<B>
Sourcepub fn new(body: B) -> ResponseBody<B>
pub fn new(body: B) -> ResponseBody<B>
Creates a response body from a concrete body value.
Sourcepub fn take_body(&mut self) -> ResponseBody<B>
pub fn take_body(&mut self) -> ResponseBody<B>
Replaces this response body with Body::None and returns the original.
Source§impl<B> ResponseBody<B>where
B: MessageBody,
impl<B> ResponseBody<B>where
B: MessageBody,
Sourcepub fn as_ref(&self) -> Option<&B>
pub fn as_ref(&self) -> Option<&B>
Returns the concrete body, if this is ResponseBody::Body.
Trait Implementations§
Source§impl<B> Debug for ResponseBody<B>where
B: Debug,
impl<B> Debug for ResponseBody<B>where
B: Debug,
Source§impl<B> From<Body> for ResponseBody<B>
impl<B> From<Body> for ResponseBody<B>
Source§fn from(b: Body) -> ResponseBody<B>
fn from(b: Body) -> ResponseBody<B>
Converts to this type from the input type.
Source§impl<B> MessageBody for ResponseBody<B>where
B: MessageBody,
impl<B> MessageBody for ResponseBody<B>where
B: MessageBody,
Source§impl<B> Stream for ResponseBody<B>where
B: MessageBody + Unpin,
impl<B> Stream for ResponseBody<B>where
B: MessageBody + Unpin,
Source§fn poll_next(
self: Pin<&mut ResponseBody<B>>,
cx: &mut Context<'_>,
) -> Poll<Option<<ResponseBody<B> as Stream>::Item>>
fn poll_next( self: Pin<&mut ResponseBody<B>>, cx: &mut Context<'_>, ) -> Poll<Option<<ResponseBody<B> as Stream>::Item>>
Attempt to pull out the next value of this stream, registering the
current task for wakeup if the value is not yet available, and returning
None if the stream is exhausted. Read moreAuto Trait Implementations§
impl<B> !RefUnwindSafe for ResponseBody<B>
impl<B> !Send for ResponseBody<B>
impl<B> !Sync for ResponseBody<B>
impl<B> !UnwindSafe for ResponseBody<B>
impl<B> Freeze for ResponseBody<B>where
B: Freeze,
impl<B> Unpin for ResponseBody<B>where
B: Unpin,
impl<B> UnsafeUnpin for ResponseBody<B>where
B: UnsafeUnpin,
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