pub struct Method(/* private fields */);
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§
§impl Method
impl Method
pub 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.
pub 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.
pub 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§
§impl<S> FromRequestParts<S> for Method
impl<S> FromRequestParts<S> for Method
§type Rejection = Infallible
type Rejection = Infallible
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
§fn from_request_parts<'life0, 'life1, 'async_trait>(
parts: &'life0 mut Parts,
_: &'life1 S
) -> Pin<Box<dyn Future<Output = Result<Method, <Method as FromRequestParts<S>>::Rejection>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Method: 'async_trait,
fn from_request_parts<'life0, 'life1, 'async_trait>(
parts: &'life0 mut Parts,
_: &'life1 S
) -> Pin<Box<dyn Future<Output = Result<Method, <Method as FromRequestParts<S>>::Rejection>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Method: 'async_trait,
Perform the extraction.
§impl<'a> PartialEq<&'a Method> for Method
impl<'a> PartialEq<&'a Method> for Method
§impl TryFrom<Method> for MethodFilter
impl TryFrom<Method> for MethodFilter
impl Eq for Method
impl StructuralPartialEq for Method
Auto Trait Implementations§
impl Freeze for Method
impl RefUnwindSafe for Method
impl Send for Method
impl Sync for Method
impl Unpin for Method
impl UnwindSafe for Method
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.