Skip to main content

ResponseWriter

Struct ResponseWriter 

Source
pub struct ResponseWriter<W: AsyncWrite + Unpin> { /* private fields */ }

Implementations§

Source§

impl<W: AsyncWrite + Unpin> ResponseWriter<W>

Source

pub fn new(writer: W) -> Self

Source

pub fn with_write_timeout(self, timeout: Option<Duration>) -> Self

Enforce a per-write deadline (see crate::HttpConfig::response_timeout).

Source

pub fn reset(&mut self)

Reset per-response state so the same writer can serve the next request on a keep-alive connection.

Source

pub fn should_close(&self) -> bool

Whether the response indicated the connection should be closed.

Source

pub async fn write_headers( &mut self, status: u16, headers: &[(&str, &str)], ) -> Result<()>

Source

pub async fn write_chunked_headers( &mut self, content_type: &str, extra_headers: &[(&str, &str)], ) -> Result<()>

Source

pub async fn write_chunk(&mut self, data: &[u8]) -> Result<()>

Source

pub async fn write_raw(&mut self, data: &[u8]) -> Result<()>

Write raw bytes directly to the stream (no chunked framing). Use with Transfer-Encoding: none / Connection: close for streaming.

Source

pub async fn write_body( &mut self, status: u16, content_type: &str, body: &[u8], ) -> Result<()>

Source

pub async fn write_json(&mut self, status: u16, json: &str) -> Result<()>

Source

pub async fn flush(&mut self) -> Result<()>

Source

pub fn into_inner(self) -> W

Auto Trait Implementations§

§

impl<W> Forget for ResponseWriter<W>

§

impl<W> Freeze for ResponseWriter<W>
where W: Freeze,

§

impl<W> Move for ResponseWriter<W>

§

impl<W> RefUnwindSafe for ResponseWriter<W>
where W: RefUnwindSafe,

§

impl<W> Send for ResponseWriter<W>
where W: Send,

§

impl<W> Sync for ResponseWriter<W>
where W: Sync,

§

impl<W> Unpin for ResponseWriter<W>

§

impl<W> UnsafeUnpin for ResponseWriter<W>
where W: UnsafeUnpin,

§

impl<W> UnwindSafe for ResponseWriter<W>
where W: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more