Trait viz_core::ResponseExt

source ·
pub trait ResponseExt: Sized {
    // Required methods
    fn ok(&self) -> bool;
    fn location(location: &'static str) -> Self;
    fn redirect<T>(url: T) -> Response
       where T: AsRef<str>;
    fn redirect_with_status<T>(uri: T, status: StatusCode) -> Response
       where T: AsRef<str>;

    // Provided methods
    fn with<T>(t: T, c: &'static str) -> Response
       where T: Into<Body> { ... }
    fn text<T>(t: T) -> Response
       where T: Into<Body> { ... }
    fn html<T>(t: T) -> Response
       where T: Into<Body> { ... }
    fn json<T>(t: T) -> Result<Response, PayloadError>
       where T: Serialize { ... }
    fn stream<S, O, E>(s: S) -> Response
       where S: Stream<Item = Result<O, E>> + Send + 'static,
             O: Into<Bytes> + 'static,
             E: Error + Send + Sync + 'static { ... }
    fn see_other<T>(url: T) -> Response
       where T: AsRef<str> { ... }
    fn temporary<T>(url: T) -> Response
       where T: AsRef<str> { ... }
    fn permanent<T>(url: T) -> Response
       where T: AsRef<str> { ... }
}
Expand description

The Response Extension.

Required Methods§

source

fn ok(&self) -> bool

The response was successful (status in the range 200-299) or not.

source

fn location(location: &'static str) -> Self

The Content-Location header indicates an alternate location for the returned data.

source

fn redirect<T>(url: T) -> Responsewhere T: AsRef<str>,

The response redirects to the specified URL.

source

fn redirect_with_status<T>(uri: T, status: StatusCode) -> Responsewhere T: AsRef<str>,

The response redirects to the specified URL and the status code.

Provided Methods§

source

fn with<T>(t: T, c: &'static str) -> Responsewhere T: Into<Body>,

The response with the specified Content-Type.

source

fn text<T>(t: T) -> Responsewhere T: Into<Body>,

The response with text/plain; charset=utf-8 media type.

source

fn html<T>(t: T) -> Responsewhere T: Into<Body>,

The response with text/html; charset=utf-8 media type.

source

fn json<T>(t: T) -> Result<Response, PayloadError>where T: Serialize,

Available on crate feature json only.

The response with application/javascript; charset=utf-8 media type.

source

fn stream<S, O, E>(s: S) -> Responsewhere S: Stream<Item = Result<O, E>> + Send + 'static, O: Into<Bytes> + 'static, E: Error + Send + Sync + 'static,

Responds to a stream.

source

fn see_other<T>(url: T) -> Responsewhere T: AsRef<str>,

The response redirects to the 303.

source

fn temporary<T>(url: T) -> Responsewhere T: AsRef<str>,

The response redirects to the 307.

source

fn permanent<T>(url: T) -> Responsewhere T: AsRef<str>,

The response redirects to the 308.

Implementors§