pub struct ResponseBody<B = BoxBody> { /* private fields */ }Expand description
A unified response body type. Generic type is for custom pinned response body(type implement Body).
Implementations§
Source§impl ResponseBody
impl ResponseBody
Source§impl<B> ResponseBody<B>
impl<B> ResponseBody<B>
Sourcepub const fn empty() -> ResponseBody<B>
pub const fn empty() -> ResponseBody<B>
indicate empty body is attached to response.
content-length: 0 header would be added to response when [BodySize] is
used for inferring response body type.
Sourcepub const fn body(stream: B) -> ResponseBody<B>
pub const fn body(stream: B) -> ResponseBody<B>
Construct a new Body variant of ResponseBody
Sourcepub fn bytes<B2>(bytes: B2) -> ResponseBody<B>
pub fn bytes<B2>(bytes: B2) -> ResponseBody<B>
Construct a new Bytes variant of ResponseBody
Sourcepub fn into_boxed<T, E>(self) -> ResponseBody
pub fn into_boxed<T, E>(self) -> ResponseBody
erase generic body type by boxing the variant.
Trait Implementations§
Source§impl<B, E> Body for ResponseBody<B>
impl<B, E> Body for ResponseBody<B>
Source§type Data = Bytes
type Data = Bytes
The payload data type yielded by
Frame::Data variants.Source§fn poll_frame(
self: Pin<&mut ResponseBody<B>>,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Frame<Bytes>, E>>>
fn poll_frame( self: Pin<&mut ResponseBody<B>>, cx: &mut Context<'_>, ) -> Poll<Option<Result<Frame<Bytes>, E>>>
Attempt to pull the next frame from the body. Read more
Source§fn is_end_stream(&self) -> bool
fn is_end_stream(&self) -> bool
Indicates whether the body has been fully consumed. Read more
Source§impl<B> Default for ResponseBody<B>
impl<B> Default for ResponseBody<B>
Source§fn default() -> ResponseBody<B>
fn default() -> ResponseBody<B>
Returns the “default value” for a type. Read more
Source§impl<B> From<&'static [u8]> for ResponseBody<B>
impl<B> From<&'static [u8]> for ResponseBody<B>
Source§fn from(item: &'static [u8]) -> ResponseBody<B>
fn from(item: &'static [u8]) -> ResponseBody<B>
Converts to this type from the input type.
Source§impl<B> From<&'static str> for ResponseBody<B>
impl<B> From<&'static str> for ResponseBody<B>
Source§fn from(item: &'static str) -> ResponseBody<B>
fn from(item: &'static str) -> ResponseBody<B>
Converts to this type from the input type.
Source§impl From<BoxBody> for ResponseBody
impl From<BoxBody> for ResponseBody
Source§fn from(body: BoxBody) -> ResponseBody
fn from(body: BoxBody) -> ResponseBody
Converts to this type from the input type.
Source§impl<B> From<Bytes> for ResponseBody<B>
impl<B> From<Bytes> for ResponseBody<B>
Source§fn from(item: Bytes) -> ResponseBody<B>
fn from(item: Bytes) -> ResponseBody<B>
Converts to this type from the input type.
Source§impl<B> From<BytesMut> for ResponseBody<B>
impl<B> From<BytesMut> for ResponseBody<B>
Source§fn from(item: BytesMut) -> ResponseBody<B>
fn from(item: BytesMut) -> ResponseBody<B>
Converts to this type from the input type.
Source§impl<B> From<ResponseBody> for CompatBody<B>where
B: From<ResponseBody>,
impl<B> From<ResponseBody> for CompatBody<B>where
B: From<ResponseBody>,
Source§fn from(body: ResponseBody) -> Self
fn from(body: ResponseBody) -> Self
Converts to this type from the input type.
Source§impl<B> From<String> for ResponseBody<B>
impl<B> From<String> for ResponseBody<B>
Source§fn from(item: String) -> ResponseBody<B>
fn from(item: String) -> ResponseBody<B>
Converts to this type from the input type.
Source§impl<'r, C, B, ResB> Responder<WebContext<'r, C, B>> for ResponseBody<ResB>
impl<'r, C, B, ResB> Responder<WebContext<'r, C, B>> for ResponseBody<ResB>
impl<'__pin, B> Unpin for ResponseBody<B>where
<PinnedFieldsOfHelperStruct<__Origin<'__pin, B>> as PinnedFieldsOfHelperTrait>::Actual: Unpin,
Auto Trait Implementations§
impl<B = BoxBody> !Freeze for ResponseBody<B>
impl<B> RefUnwindSafe for ResponseBody<B>where
B: RefUnwindSafe,
impl<B> Send for ResponseBody<B>where
B: Send,
impl<B> Sync for ResponseBody<B>where
B: Sync,
impl<B> UnsafeUnpin for ResponseBody<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for ResponseBody<B>where
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