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§
source§impl Method
impl Method
sourcepub 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§
source§impl<'de> Deserialize<'de> for Method
impl<'de> Deserialize<'de> for Method
source§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
source§impl<'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.
source§impl PartialEq<Method> for Method
impl PartialEq<Method> for Method
source§impl<'a> Serialize for Method
impl<'a> Serialize for Method
source§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§
§impl<'a, T> AsTaggedExplicit<'a> for Twhere
T: 'a,
impl<'a, T> AsTaggedExplicit<'a> for Twhere T: 'a,
§impl<'a, T> AsTaggedImplicit<'a> for Twhere
T: 'a,
impl<'a, T> AsTaggedImplicit<'a> for Twhere T: 'a,
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.