Struct http_serve::BodyWriter[][src]

pub struct BodyWriter<D, E>(_)
where
    D: From<Vec<u8>> + Send + 'static,
    E: Send + 'static
;
Expand description

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

Causes the HTTP connection to be dropped abruptly. The actual value of error is mostly irrelevant, although hyper may choose to log it.

Trait Implementations

Write a buffer into this writer, returning how many bytes were written. Read more

Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more

Like write, except that it writes from a slice of buffers. Read more

🔬 This is a nightly-only experimental API. (can_vector)

Determines if this Writer has an efficient write_vectored implementation. Read more

Attempts to write an entire buffer into this writer. Read more

🔬 This is a nightly-only experimental API. (write_all_vectored)

Attempts to write multiple buffers into this writer. Read more

Writes a formatted string into this writer, returning any error encountered. Read more

Creates a “by reference” adapter for this instance of Write. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.