pub struct Response { /* private fields */ }Expand description
One response, written whole or streamed.
Implementations§
Source§impl Response
impl Response
Sourcepub fn new(status: u16, content_type: &'static str, body: Vec<u8>) -> Self
pub fn new(status: u16, content_type: &'static str, body: Vec<u8>) -> Self
body with status and its content type.
Sourcepub fn stream(
content_type: &'static str,
body: impl FnOnce(&mut dyn Write) -> Result<()> + Send + 'static,
) -> Self
pub fn stream( content_type: &'static str, body: impl FnOnce(&mut dyn Write) -> Result<()> + Send + 'static, ) -> Self
A 200 whose body body writes after the head, as it is made, until it
returns; the connection’s close then ends it. It is never cached.
Sourcepub const fn cached(self, policy: &'static str) -> Self
pub const fn cached(self, policy: &'static str) -> Self
The same response kept by caches as policy says, in place of
no-store.
Sourcepub fn no_content() -> Self
pub fn no_content() -> Self
A 204: no body, so no Content-Type and no Content-Length.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Response
impl !Sync for Response
impl !UnwindSafe for Response
impl Freeze for Response
impl Send for Response
impl Unpin for Response
impl UnsafeUnpin for Response
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
Source§fn into_maybe_undefined(self) -> MaybeUndefined<T>
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Converts this value into a three-state builder argument.
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Converts this value into an optional builder argument.