Enum rocket_governor::Method
[−]pub enum Method {
Get,
Put,
Post,
Delete,
Options,
Head,
Trace,
Connect,
Patch,
}
Expand description
Representation of HTTP methods.
(De)serialization
Method
is both Serialize
and Deserialize
, represented as an
uncased string. For example, Method::Get
serializes to
"GET"
and deserializes from any casing of "GET"
including "get"
,
"GeT"
, and "GET"
.
use serde::{Serialize, Deserialize};
use rocket::http::Method;
#[derive(Deserialize, Serialize)]
struct Foo {
method: Method,
}
Variants
Get
The GET
variant.
Put
The PUT
variant.
Post
The POST
variant.
Delete
The DELETE
variant.
Options
The OPTIONS
variant.
Head
The HEAD
variant.
Trace
The TRACE
variant.
Connect
The CONNECT
variant.
Patch
The PATCH
variant.
Implementations
impl Method
impl Method
pub fn supports_payload(self) -> bool
pub fn supports_payload(self) -> bool
Returns true
if an HTTP request with the method represented by self
always supports a payload.
The following methods always support payloads:
PUT
,POST
,DELETE
,PATCH
The following methods do not always support payloads:
GET
,HEAD
,CONNECT
,TRACE
,OPTIONS
Example
use rocket::http::Method;
assert_eq!(Method::Get.supports_payload(), false);
assert_eq!(Method::Post.supports_payload(), true);
Trait Implementations
impl<'de> Deserialize<'de> for Method
impl<'de> Deserialize<'de> for Method
fn deserialize<D>(
deserializer: D
) -> Result<Method, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<Method, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<'r> FromRequest<'r> for Method
impl<'r> FromRequest<'r> for Method
type Error = Infallible
type Error = Infallible
The associated error to be returned if derivation fails.
sourcefn from_request<'life0, 'async_trait>(
request: &'r Request<'life0>
) -> Pin<Box<dyn Future<Output = Outcome<Method, (Status, <Method as FromRequest<'r>>::Error), ()>> + Send + 'async_trait, Global>> where
'r: 'async_trait,
'life0: 'async_trait,
Method: 'async_trait,
fn from_request<'life0, 'async_trait>(
request: &'r Request<'life0>
) -> Pin<Box<dyn Future<Output = Outcome<Method, (Status, <Method as FromRequest<'r>>::Error), ()>> + Send + 'async_trait, Global>> where
'r: 'async_trait,
'life0: 'async_trait,
Method: 'async_trait,
Derives an instance of Self
from the incoming request metadata. Read more
impl<'a> Serialize for Method
impl<'a> Serialize for Method
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl Copy for Method
impl Eq for Method
impl StructuralEq for Method
impl StructuralPartialEq for Method
Auto Trait Implementations
impl RefUnwindSafe for Method
impl Send for Method
impl Sync for Method
impl Unpin for Method
impl UnwindSafe for Method
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<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
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