pub enum Response<T> {
Body(T),
WithStatus(StatusCode, T),
Raw(StatusCode, Body),
Empty,
WithCookies(Box<Response<T>>, Vec<Cookie>),
}Expand description
Re-exported public API.
Public Caelix enumeration Response.
Variants§
Body(T)
Public Caelix API.
WithStatus(StatusCode, T)
Public Caelix API.
Raw(StatusCode, Body)
Public Caelix API.
Empty
Public Caelix API.
WithCookies(Box<Response<T>>, Vec<Cookie>)
Adds cookies after materializing the wrapped response.
Implementations§
Source§impl Response<()>
impl Response<()>
Sourcepub fn no_content() -> Self
pub fn no_content() -> Self
Runs the no_content public API operation.
Sourcepub fn text(status: StatusCode, value: impl Into<String>) -> Self
pub fn text(status: StatusCode, value: impl Into<String>) -> Self
Runs the text public API operation.
Sourcepub fn bytes(status: StatusCode, value: impl Into<Vec<u8>>) -> Self
pub fn bytes(status: StatusCode, value: impl Into<Vec<u8>>) -> Self
Runs the bytes public API operation.
Sourcepub fn json(status: StatusCode, value: impl Serialize) -> Self
pub fn json(status: StatusCode, value: impl Serialize) -> Self
Runs the json public API operation.
Sourcepub fn stream(
content_type: &'static str,
stream: impl Stream<Item = Result<Bytes>> + Send + 'static,
) -> HttpResponse
pub fn stream( content_type: &'static str, stream: impl Stream<Item = Result<Bytes>> + Send + 'static, ) -> HttpResponse
Stream response chunks as they become ready (chunked transfer encoding is applied by the HTTP adapter).
Sourcepub fn sse<T>(
stream: impl Stream<Item = Result<T>> + Send + 'static,
) -> HttpResponsewhere
T: Serialize + 'static,
pub fn sse<T>(
stream: impl Stream<Item = Result<T>> + Send + 'static,
) -> HttpResponsewhere
T: Serialize + 'static,
Server-Sent Events: each item is serialized as JSON and framed as
data: <json>\n\n with content type text/event-stream.
Also sets Cache-Control: no-cache and X-Accel-Buffering: no so
proxies/browsers do not buffer the stream. Does not yet implement the
full SSE protocol (id:, event:, retry:, Last-Event-ID).
Trait Implementations§
Source§impl<T: Serialize> IntoCaelixResponse for Response<T>
impl<T: Serialize> IntoCaelixResponse for Response<T>
Source§fn into_response(self) -> HttpResponse
fn into_response(self) -> HttpResponse
Public Caelix API.
Auto Trait Implementations§
impl<T> Freeze for Response<T>where
T: Freeze,
impl<T> RefUnwindSafe for Response<T>where
T: RefUnwindSafe,
impl<T> Send for Response<T>where
T: Send,
impl<T> Sync for Response<T>where
T: Sync,
impl<T> Unpin for Response<T>where
T: Unpin,
impl<T> UnsafeUnpin for Response<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Response<T>where
T: 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