Module rustful::response
[−]
[src]
Response writers.
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 Response
as
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
correct.
No extra overhead | Guaranteed correct content-length | Streaming | |
---|---|---|---|
Response | ✓ | ✓ | ✗ |
Raw | ✓ | ✗ | ✓ |
Chunked | ✗ | ✓ | ✓ |
Structs
Chunked |
An interface for writing a chunked response body. |
Raw |
A streaming fixed-size response. |
Response |
An interface for sending data to the client. |
Enums
Data |
A unified representation of response data. |
Error |
The result of a response action. |
FileError |
Error that may occure while sending a file. |
Traits
ResponseError |
Helper trait for dealing with errors that may occur while sending a response. It provides a default method of handling the error. |
SendResponse |
A trait for higher level types that can be sent as responses, like
|