Trait warp::reply::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>