Type Definition rocket::handler::Outcome [−][src]
type Outcome<'r> = Outcome<Response<'r>, Status, Data>;
Expand description
Type alias for the Outcome of a Handler.
Implementations
impl<'r> Outcome<'r>[src]
impl<'r> Outcome<'r>[src]pub fn from<T: Responder<'r>>(req: &Request<'_>, responder: T) -> Outcome<'r>[src]
pub fn from<T: Responder<'r>>(req: &Request<'_>, responder: T) -> Outcome<'r>[src]Return the Outcome of response to req from responder.
If the responder returns Ok, an outcome of Success is
returned with the response. If the responder returns Err, an
outcome of Failure is returned with the status code.
Example
use rocket::{Request, Data}; use rocket::handler::Outcome; fn str_responder(req: &Request, _: Data) -> Outcome<'static> { Outcome::from(req, "Hello, world!") }
pub fn from_or_forward<T>(
req: &Request<'_>,
data: Data,
responder: T
) -> Outcome<'r> where
T: Responder<'r>, [src]
pub fn from_or_forward<T>(
req: &Request<'_>,
data: Data,
responder: T
) -> Outcome<'r> where
T: Responder<'r>, [src]Return the Outcome of response to req from responder.
If the responder returns Ok, an outcome of Success is
returned with the response. If the responder returns Err, an
outcome of Forward is returned.
Example
use rocket::{Request, Data}; use rocket::handler::Outcome; fn str_responder(req: &Request, data: Data) -> Outcome<'static> { Outcome::from_or_forward(req, data, "Hello, world!") }
pub fn failure(code: Status) -> Outcome<'static>[src]
pub fn failure(code: Status) -> Outcome<'static>[src]Return an Outcome of Failure with the status code code. This is
equivalent to Outcome::Failure(code).
This method exists to be used during manual routing where
rocket::handler::Outcome is imported instead of rocket::Outcome.
Example
use rocket::{Request, Data}; use rocket::handler::Outcome; use rocket::http::Status; fn bad_req_route(_: &Request, _: Data) -> Outcome<'static> { Outcome::failure(Status::BadRequest) }
pub fn forward(data: Data) -> Outcome<'static>[src]
pub fn forward(data: Data) -> Outcome<'static>[src]Return an Outcome of Forward with the data data. This is
equivalent to Outcome::Forward(data).
This method exists to be used during manual routing where
rocket::handler::Outcome is imported instead of rocket::Outcome.
Example
use rocket::{Request, Data}; use rocket::handler::Outcome; fn always_forward(_: &Request, data: Data) -> Outcome<'static> { Outcome::forward(data) }