warp::reply

Trait Reply

Source
pub trait Reply: BoxedReply + Send {
    // Required method
    fn into_response(self) -> Response;
}
Expand description

Types that can be converted into a Response.

This trait is implemented for the following:

  • http::StatusCode
  • http::Response<impl Into<hyper::Body>>
  • String
  • &'static str

§Example

use warp::{Filter, http::Response};

struct Message {
    msg: String
}

impl warp::Reply for Message {
    fn into_response(self) -> warp::reply::Response {
        Response::new(format!("message: {}", self.msg).into())
    }
}

fn handler() -> Message {
    Message { msg: "Hello".to_string() }
}

let route = warp::any().map(handler);

Required Methods§

Source

fn into_response(self) -> Response

Converts the given value into a Response.

Implementations on Foreign Types§

Source§

impl Reply for &'static str

Source§

impl Reply for &'static [u8]

Source§

impl Reply for Cow<'static, str>

Source§

impl Reply for Infallible

Source§

impl Reply for Error

Source§

impl Reply for StatusCode

Source§

impl Reply for String

Source§

impl Reply for Vec<u8>

Source§

impl<T> Reply for (T,)
where T: Reply,

Source§

impl<T, E> Reply for Result<T, E>
where T: Reply, E: Reply,

Source§

impl<T: Send> Reply for Response<T>
where Body: From<T>,

Source§

impl<T: Reply + ?Sized> Reply for Box<T>

Implementors§

Source§

impl Reply for File

Source§

impl Reply for Json

Source§

impl<T> Reply for Html<T>
where Body: From<T>, T: Send,

Source§

impl<T: Reply> Reply for WithHeader<T>

Source§

impl<T: Reply> Reply for WithStatus<T>