The response writers are the output channel from the handlers to the client. These are used to set the response headers, as well as writing the response body. Rustful provides three different types of response writers with different purposes:
Response- It's used to write data with a known, fixed size, that is already stored in some kind of buffer.
Chunked- A chunked response is a streaming response, where the final size can be unknown.
Raw- This is also a streaming response, but with a fixed size. It is unsafe to create because of the risk of sending too short responses, but it can be very useful in cases where it's impractical to buffer the data, such as when sending large files.
You will always start out with a
Response, where you can set the status
code and all the headers, and then transform it into one of the other
types, if necessary. It is usually recommended to stick to
much as possible, since it has lower HTTP overhead than
Chunked and has a
builtin size check that guarantees that the
content-length field is
|No extra overhead|| Guaranteed correct ||Streaming|
An interface for writing a chunked response body.
A streaming fixed-size response.
An interface for sending data to the client.
A unified representation of response data.
The result of a response action.
Error that may occure while sending a file.
Helper trait for dealing with errors that may occur while sending a response. It provides a default method of handling the error.
A trait for higher level types that can be sent as responses, like