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)
see NamedFile
NotFound(NotFound<T>)
see NoContent
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>)
see Unauthorized
Vec(Vec<u8>)
see Vec
Xml(RawXml<T>)
see Xml
Trait Implementations
sourceimpl<'r, 'o: 'r, T, U> Responder<'r, 'o> for RocketResponseGeneric2<T, U> where
T: Serialize,
Accepted<T>: Responder<'r, 'o>,
BadRequest<T>: Responder<'r, 'o>,
Conflict<T>: Responder<'r, 'o>,
Created<T>: Responder<'r, 'o>,
RawCss<T>: Responder<'r, 'o>,
Flash<U>: Responder<'r, 'o>,
Forbidden<T>: Responder<'r, 'o>,
RawHtml<T>: Responder<'r, 'o>,
RawJavaScript<T>: Responder<'r, 'o>,
RawJson<T>: Responder<'r, 'o>,
RawMsgPack<T>: Responder<'r, 'o>,
NotFound<T>: Responder<'r, 'o>,
RawText<T>: Responder<'r, 'o>,
Unauthorized<T>: Responder<'r, 'o>,
RawXml<T>: Responder<'r, 'o>,
impl<'r, 'o: 'r, T, U> Responder<'r, 'o> for RocketResponseGeneric2<T, U> where
T: Serialize,
Accepted<T>: Responder<'r, 'o>,
BadRequest<T>: Responder<'r, 'o>,
Conflict<T>: Responder<'r, 'o>,
Created<T>: Responder<'r, 'o>,
RawCss<T>: Responder<'r, 'o>,
Flash<U>: Responder<'r, 'o>,
Forbidden<T>: Responder<'r, 'o>,
RawHtml<T>: Responder<'r, 'o>,
RawJavaScript<T>: Responder<'r, 'o>,
RawJson<T>: Responder<'r, 'o>,
RawMsgPack<T>: Responder<'r, 'o>,
NotFound<T>: Responder<'r, 'o>,
RawText<T>: Responder<'r, 'o>,
Unauthorized<T>: Responder<'r, 'o>,
RawXml<T>: Responder<'r, 'o>,
sourcefn respond_to(self, __req: &'r Request<'_>) -> Result<'o>
fn respond_to(self, __req: &'r Request<'_>) -> Result<'o>
Returns Ok
if a Response
could be generated successfully. Otherwise,
returns an Err
with a failing Status
. Read more
Auto Trait Implementations
impl<T, U> !RefUnwindSafe for RocketResponseGeneric2<T, U>
impl<T, U> Send for RocketResponseGeneric2<T, U> where
T: Send,
U: Send,
impl<T, U> Sync for RocketResponseGeneric2<T, U> where
T: Sync,
U: Sync,
impl<T, U> Unpin for RocketResponseGeneric2<T, U> where
T: Unpin,
U: Unpin,
impl<T, U> UnwindSafe for RocketResponseGeneric2<T, U> where
T: UnwindSafe,
U: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> IntoCollection<T> for T
impl<T> IntoCollection<T> for T
fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
Converts self
into a collection.
fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
F: FnMut(T) -> U,
A: Array<Item = U>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more