[−][src]Struct http_serve::BodyWriter
A std::io::Write
implementation that makes a chunked hyper response body stream.
Automatically applies gzip
content encoding if requested by the client.
The stream is infinitely buffered; calls to write
and flush
never block. flush
thus is a
hint that data should be sent to the client as soon as possible, but this shouldn't be expected
to happen before it returns. write
and flush
may return error; this indicates that the
client certainly won't receive any additional bytes, so the calling code should stop producing
them.
The infinite buffering avoids the need for calling code to deal with backpressure via futures or blocking. Many applications anyway produce output while holding a lock or database transaction that should finish quickly, so backpressure must be ignored anyway.
On drop, the stream will be "finished" (for gzip, this writes a special footer). There's no way to know the complete stream was written successfully. It's inherent in the combination of HTTP / TCP / Unix sockets / hyper anyway that only the client knows this.
Implementations
impl<D, E> BodyWriter<D, E> where
D: From<Vec<u8>> + Send + 'static,
E: Send + 'static,
[src]
D: From<Vec<u8>> + Send + 'static,
E: Send + 'static,
Trait Implementations
impl<D, E> Write for BodyWriter<D, E> where
D: From<Vec<u8>> + Send + 'static,
E: Send + 'static,
[src]
D: From<Vec<u8>> + Send + 'static,
E: Send + 'static,
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize, Error>
1.36.0[src]
fn is_write_vectored(&self) -> bool
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_all_vectored(&mut self, bufs: &mut [IoSlice]) -> Result<(), Error>
[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl<D, E> !RefUnwindSafe for BodyWriter<D, E>
impl<D, E> Send for BodyWriter<D, E>
impl<D, E> Sync for BodyWriter<D, E>
impl<D, E> Unpin for BodyWriter<D, E>
impl<D, E> !UnwindSafe for BodyWriter<D, E>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Sealed<T> for T where
T: ?Sized,
T: ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,