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

The non-generic and generic Responses with 2 types.

Example usage

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

#[get("/<id>")]
pub(crate) fn rocket_response_generic2(
    id: usize,
) -> RocketResponse<&'static str, Redirect> {
    match id {
        0 => RocketResponse::Flash(response::Flash::error(
          Redirect::to("/"),
            format!("Invalid id {}", id),
        )),
        1 => RocketResponse::Unauthorized(status::Unauthorized(Some(
            "admin need authentication",
        ))),
        _ => RocketResponse::Html(response::content::RawHtml(
            "<html><body>Hello world</body></html",
        )),
    }
}

Variants

Accepted(Accepted<T>)

BadRequest(BadRequest<T>)

Conflict(Conflict<T>)

Created(Created<T>)

Css(RawCss<T>)

File(File)

see File

Flash(Flash<U>)

with generic type U
see rocket::response::Flash

Forbidden(Forbidden<T>)

Html(RawHtml<T>)

JavaScript(RawJavaScript<T>)

Json(RawJson<T>)

MsgPack(RawMsgPack<T>)

NamedFiled(NamedFile)

NotFound(NotFound<T>)

NoContent(NoContent)

Plain(RawText<T>)

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<T>)

Vec(Vec<u8>)

see Vec

Xml(RawXml<T>)

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