pub enum ResponseBody {
Complete(Vec<u8>),
Stream(Pin<Box<dyn Stream<Item = Result<Bytes>> + Send>>),
Subscription(Subscription, ContentType),
}Expand description
Response body — complete or streaming.
Variants§
Complete(Vec<u8>)
Complete response body
Stream(Pin<Box<dyn Stream<Item = Result<Bytes>> + Send>>)
Streaming response body (for large datasets)
Subscription(Subscription, ContentType)
Real-time subscription tagged with the negotiated streaming format
(Sse, GrpcWeb, …). The HTTP layer looks the format up in its
subscription-encoder registry to produce the wire response — the
format travels as a type, not a re-parsed Content-Type header.
Implementations§
Source§impl ResponseBody
impl ResponseBody
Sourcepub const fn subscription(sub: Subscription, format: ContentType) -> Self
pub const fn subscription(sub: Subscription, format: ContentType) -> Self
Create a subscription response body tagged with the negotiated streaming format the HTTP layer should encode it as.
Sourcepub fn into_bytes(self) -> Option<Vec<u8>>
pub fn into_bytes(self) -> Option<Vec<u8>>
Extract bytes from a Complete response body.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ResponseBody
impl !Sync for ResponseBody
impl !UnwindSafe for ResponseBody
impl Freeze for ResponseBody
impl Send for ResponseBody
impl Unpin for ResponseBody
impl UnsafeUnpin for ResponseBody
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