Skip to main content

Res

Trait Res 

pub trait Res {
    // Required methods
    fn error_response(path: &str, err: Bytes) -> Self;
    fn redirect(&mut self, path: &str);

    // Provided method
    fn content_type(&mut self, content_type: &str) { ... }
}
Expand description

Represents the response as created by the server;

Required Methodsยง

fn error_response(path: &str, err: Bytes) -> Self

Converts an error into a response, with a 500 status code and the error as its body.

fn redirect(&mut self, path: &str)

Redirect the response by setting a 302 code and Location header.

Provided Methodsยง

fn content_type(&mut self, content_type: &str)

Set the Content-Type header for the response.

Dyn Compatibilityยง

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Typesยง

ยง

impl Res for Response<Body>

ยง

fn error_response(path: &str, err: Bytes) -> Response<Body>

ยง

fn content_type(&mut self, content_type: &str)

ยง

fn redirect(&mut self, path: &str)

ยง

impl Res for Response<Body>

ยง

fn error_response(path: &str, err: Bytes) -> Response<Body>

ยง

fn content_type(&mut self, content_type: &str)

ยง

fn redirect(&mut self, path: &str)

Implementorsยง