Enum rocket_response::RocketResponseGeneric2 [−][src]
pub enum RocketResponseGeneric2<T, U> where
T: Serialize, {}Show 26 variants
Accepted(Accepted<T>), BadRequest(BadRequest<T>), Conflict(Conflict<T>), Created(Created<T>), Css(Css<T>), Custom(Custom<T>), File(File), Flash(Flash<U>), Forbidden(Forbidden<T>), Html(Html<T>), JavaScript(JavaScript<T>), Json(Json<T>), MsgPack(MsgPack<T>), NamedFiled(NamedFile), NotFound(NotFound<T>), NoContent(NoContent), Plain(Plain<T>), Redirect(Redirect), StaticSlice(&'static [u8]), StaticStr(&'static str), String(String), Status(Status), TokioFile(File), Unauthorized(Unauthorized<T>), Vec(Vec<u8>), Xml(Xml<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::Html( "<html><body>Hello world</body></html", )), } }
Variants
Accepted(Accepted<T>)BadRequest(BadRequest<T>)Conflict(Conflict<T>)Created(Created<T>)Css(Css<T>)Custom(Custom<T>)File(File)see File
Flash(Flash<U>)with generic type U
see rocket::response::Flash
Forbidden(Forbidden<T>)Html(Html<T>)JavaScript(JavaScript<T>)Json(Json<T>)MsgPack(MsgPack<T>)NamedFiled(NamedFile)see NamedFile
NotFound(NotFound<T>)see NoContent
NoContent(NoContent)Plain(Plain<T>)Redirect(Redirect)StaticSlice(&'static [u8])see slice
StaticStr(&'static str)see str
String(String)see String
see Status
see File
see Unauthorized
see Vec
Xml(Xml<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
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>Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
pub fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
pub fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>, Converts self into a collection.
pub fn vzip(self) -> V