pub enum RocketResponse {
Show 25 variants Accepted(Accepted<&'static str>), BadRequest(BadRequest<&'static str>), Conflict(Conflict<&'static str>), Created(Created<&'static str>), Css(RawCss<&'static str>), File(File), Flash(Flash<&'static str>), Forbidden(Forbidden<&'static str>), Html(RawHtml<&'static str>), JavaScript(RawJavaScript<&'static str>), Json(RawJson<&'static str>), MsgPack(RawMsgPack<&'static str>), NamedFiled(NamedFile), NotFound(NotFound<&'static str>), NoContent(NoContent), Plain(RawText<&'static str>), Redirect(Redirect), StaticSlice(&'static [u8]), StaticStr(&'static str), String(String), Status(Status), TokioFile(File), Unauthorized(Unauthorized<&'static str>), Vec(Vec<u8>), Xml(RawXml<&'static str>),
}
Expand description

The non-generic Responses.

Example usage

use rocket::{get, response::{self, Redirect}};
use rocket_response::RocketResponse;

#[get("/<id>")]
pub(crate) fn route_example(id: usize) -> RocketResponse {
    match id {
        0 => RocketResponse::NoContent(response::status::NoContent),
        1 => RocketResponse::Redirect(Redirect::to("/admin")),
        _ => RocketResponse::StaticStr("Hello world"),
    }
}

Variants

Accepted(Accepted<&'static str>)

BadRequest(BadRequest<&'static str>)

Conflict(Conflict<&'static str>)

Created(Created<&'static str>)

Css(RawCss<&'static str>)

File(File)

see File

Flash(Flash<&'static str>)

Forbidden(Forbidden<&'static str>)

Html(RawHtml<&'static str>)

JavaScript(RawJavaScript<&'static str>)

Json(RawJson<&'static str>)

MsgPack(RawMsgPack<&'static str>)

NamedFiled(NamedFile)

NotFound(NotFound<&'static str>)

NoContent(NoContent)

Plain(RawText<&'static str>)

Redirect(Redirect)

StaticSlice(&'static [u8])

see slice

StaticStr(&'static str)

see str

String(String)

see String

Status(Status)

see Status

TokioFile(File)

see File

Unauthorized(Unauthorized<&'static str>)

Vec(Vec<u8>)

see Vec

Xml(RawXml<&'static str>)

see Xml

Trait Implementations

Returns Ok if a Response could be generated successfully. Otherwise, returns an Err with a failing Status. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts self into a collection.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more