pub struct ResponseWriter<W: AsyncWrite + Unpin> { /* private fields */ }Implementations§
Source§impl<W: AsyncWrite + Unpin> ResponseWriter<W>
impl<W: AsyncWrite + Unpin> ResponseWriter<W>
pub fn new(writer: W) -> Self
Sourcepub fn with_write_timeout(self, timeout: Option<Duration>) -> Self
pub fn with_write_timeout(self, timeout: Option<Duration>) -> Self
Enforce a per-write deadline (see crate::HttpConfig::response_timeout).
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset per-response state so the same writer can serve the next request on a keep-alive connection.
Sourcepub fn should_close(&self) -> bool
pub fn should_close(&self) -> bool
Whether the response indicated the connection should be closed.
pub async fn write_headers( &mut self, status: u16, headers: &[(&str, &str)], ) -> Result<()>
pub async fn write_chunked_headers( &mut self, content_type: &str, extra_headers: &[(&str, &str)], ) -> Result<()>
pub async fn write_chunk(&mut self, data: &[u8]) -> Result<()>
Sourcepub async fn write_raw(&mut self, data: &[u8]) -> Result<()>
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.
pub async fn write_body( &mut self, status: u16, content_type: &str, body: &[u8], ) -> Result<()>
pub async fn write_json(&mut self, status: u16, json: &str) -> Result<()>
pub async fn flush(&mut self) -> Result<()>
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> 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