use data::Data; use outcome::{self, Outcome}; use http::hyper::StatusCode; use response::{Responder, status}; /// Type alias for the `Outcome` of a `Handler`. pub type Response<'a> = outcome::Outcome, StatusCode, Data>; impl<'a> Response<'a> { #[inline(always)] pub fn success(responder: T) -> Response<'a> { Outcome::Success(Box::new(responder)) } #[inline(always)] pub fn failure(code: StatusCode) -> Response<'static> { Outcome::Failure(code) } #[inline(always)] pub fn forward(data: Data) -> Response<'static> { Outcome::Forward(data) } #[inline(always)] pub fn with_raw_status(status: u16, body: T) -> Response<'a> { let status_code = StatusCode::from_u16(status); Response::success(status::Custom(status_code, body)) } #[doc(hidden)] #[inline(always)] pub fn responder(self) -> Option> { self.succeeded() } }