pub trait ResponseWriter: Send {
// Required methods
fn header(&mut self) -> &mut Header;
fn write(&mut self, buf: &[u8]) -> Result<usize, HttpError>;
fn write_header(&mut self, status_code: u16);
}Expand description
The interface a handler uses to construct an HTTP response.
Port of Go’s http.ResponseWriter.
Required Methods§
Sourcefn header(&mut self) -> &mut Header
fn header(&mut self) -> &mut Header
Access the response headers (call before write_header or first write).
Sourcefn write(&mut self, buf: &[u8]) -> Result<usize, HttpError>
fn write(&mut self, buf: &[u8]) -> Result<usize, HttpError>
Write body bytes. Implicitly calls write_header(200) on the first call.
Sourcefn write_header(&mut self, status_code: u16)
fn write_header(&mut self, status_code: u16)
Send the status code and headers. Can only be called once; subsequent calls are ignored.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".