[][src]Trait warp::reply::Reply

pub trait Reply: BoxedReply + Send {
    fn into_response(self) -> Response;
}

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

fn into_response(self) -> Response

Converts the given value into a Response.

Loading content...

Implementations on Foreign Types

impl<T: Reply + ?Sized> Reply for Box<T>[src]

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

impl Reply for StatusCode[src]

impl<T> Reply for Result<T, Error> where
    T: Reply + Send
[src]

impl Reply for String[src]

impl Reply for Vec<u8>[src]

impl Reply for &'static str[src]

impl Reply for Cow<'static, str>[src]

impl Reply for &'static [u8][src]

impl<T> Reply for (T,) where
    T: Reply
[src]

impl Reply for Infallible[src]

Loading content...

Implementors

impl Reply for File[src]

impl Reply for Json[src]

impl<T: Reply> Reply for WithHeader<T>[src]

impl<T: Reply> Reply for WithStatus<T>[src]

Loading content...