pub struct Method(_);
Expand description
The Request Method (VERB)
This type also contains constants for a number of common HTTP methods such as GET, POST, etc.
Currently includes 8 variants representing the 8 methods defined in RFC 7230, plus PATCH, and an Extension variant for all extensions.
Examples
use http::Method;
assert_eq!(Method::GET, Method::from_bytes(b"GET").unwrap());
assert!(Method::GET.is_idempotent());
assert_eq!(Method::POST.as_str(), "POST");
Implementations
sourceimpl Method
impl Method
sourcepub fn from_bytes(src: &[u8]) -> Result<Method, InvalidMethod>
pub fn from_bytes(src: &[u8]) -> Result<Method, InvalidMethod>
Converts a slice of bytes to an HTTP method.
sourcepub fn is_safe(&self) -> bool
pub fn is_safe(&self) -> bool
Whether a method is considered “safe”, meaning the request is essentially read-only.
See the spec for more words.
sourcepub fn is_idempotent(&self) -> bool
pub fn is_idempotent(&self) -> bool
Whether a method is considered “idempotent”, meaning the request has the same result if executed multiple times.
See the spec for more words.
Trait Implementations
sourceimpl From<AccessControlRequestMethod> for Method
impl From<AccessControlRequestMethod> for Method
sourcefn from(method: AccessControlRequestMethod) -> Method
fn from(method: AccessControlRequestMethod) -> Method
Converts to this type from the input type.
sourceimpl From<Method> for AccessControlRequestMethod
impl From<Method> for AccessControlRequestMethod
sourcefn from(method: Method) -> AccessControlRequestMethod
fn from(method: Method) -> AccessControlRequestMethod
Converts to this type from the input type.
sourceimpl FromIterator<Method> for AccessControlAllowMethods
impl FromIterator<Method> for AccessControlAllowMethods
sourcefn from_iter<I>(iter: I) -> AccessControlAllowMethodswhere
I: IntoIterator<Item = Method>,
fn from_iter<I>(iter: I) -> AccessControlAllowMethodswhere
I: IntoIterator<Item = Method>,
Creates a value from an iterator. Read more
sourceimpl FromIterator<Method> for Allow
impl FromIterator<Method> for Allow
sourceimpl<'a> FromRequest<'a> for Method
impl<'a> FromRequest<'a> for Method
sourcefn from_request<'life0, 'async_trait>(
req: &'a Request,
_body: &'life0 mut RequestBody
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
'a: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn from_request<'life0, 'async_trait>(
req: &'a Request,
_body: &'life0 mut RequestBody
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
'a: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Extract from request head and body.
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<T> AsUncased for Twhere
T: AsRef<str> + ?Sized,
impl<T> AsUncased for Twhere
T: AsRef<str> + ?Sized,
fn as_uncased(&self) -> &UncasedStr
fn as_uncased(&self) -> &UncasedStr
Convert
self
to an [UncasedStr
].sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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 Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
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.