Struct Method

struct Method(_)

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

fn from_bytes(src: &[u8]) -> Result<Method, InvalidMethod>

Converts a slice of bytes to an HTTP method.

fn is_safe(self: &Self) -> bool

Whether a method is considered "safe", meaning the request is essentially read-only.

See the spec for more words.

fn is_idempotent(self: &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.

fn as_str(self: &Self) -> &str

Return a &str representation of the HTTP method

impl AsRef for Method

fn as_ref(self: &Self) -> &str

impl Clone for Method

fn clone(self: &Self) -> Method

impl Debug for Method

fn fmt(self: &Self, f: &mut fmt::Formatter<'_>) -> fmt::Result

impl Default for Method

fn default() -> Method

impl Display for Method

fn fmt(self: &Self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result

impl Eq for Method

impl Freeze for Method

impl FromStr for Method

fn from_str(t: &str) -> Result<Self, <Self as >::Err>

impl Hash for Method

fn hash<__H: $crate::hash::Hasher>(self: &Self, state: &mut __H)

impl PartialEq for Method

fn eq(self: &Self, other: &Method) -> bool

impl PartialEq for Method

fn eq(self: &Self, other: &str) -> bool

impl RefUnwindSafe for Method

impl Send for Method

impl StructuralPartialEq for Method

impl Sync for Method

impl Unpin for Method

impl UnwindSafe for Method

impl<'a> From for Method

fn from(t: &'a Method) -> Self

impl<'a> PartialEq for Method

fn eq(self: &Self, other: &&'a str) -> bool

impl<'a> PartialEq for Method

fn eq(self: &Self, other: &&'a Method) -> bool

impl<'a> TryFrom for Method

fn try_from(t: &'a [u8]) -> Result<Self, <Self as >::Error>

impl<'a> TryFrom for Method

fn try_from(t: &'a str) -> Result<Self, <Self as >::Error>

impl<T> Any for Method

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Method

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Method

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Method

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for Method

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Method

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T> ToString for Method

fn to_string(self: &Self) -> String

impl<T, U> Into for Method

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Method

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Method

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>