Reply

Trait Reply 

Source
pub trait Reply: BoxedReply + Send {
    // Required method
    fn into_response(self) -> Response<Body>;
}
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<Body>

Converts the given value into a Response.

Trait Implementations§

Source§

impl Entity for dyn Reply

Source§

fn type_name() -> Cow<'static, str>

String uniquely identifying this type, respecting component naming pattern. Read more
Source§

fn describe(d: &mut ComponentDescriptor) -> ComponentOrInlineSchema

Describe this entity, and the components it (may) requires.
Source§

impl ResponseEntity for dyn Reply

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 String

Source§

impl Reply for Vec<u8>

Source§

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

Source§

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

Source§

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

Implementors§

Source§

impl Reply for File

Source§

impl Reply for StatusCode

Source§

impl Reply for rweb::reply::Json

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<T> Reply for rweb::Json<T>
where T: Serialize + Send,