Skip to main content

ResponseWriter

Trait ResponseWriter 

Source
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§

Source

fn header(&mut self) -> &mut Header

Access the response headers (call before write_header or first write).

Source

fn write(&mut self, buf: &[u8]) -> Result<usize, HttpError>

Write body bytes. Implicitly calls write_header(200) on the first call.

Source

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".

Implementors§