Skip to main content

Method

Struct Method 

Source
pub struct Method(/* private fields */);
Expand description

A validated HTTP method.

Standard methods (GET, HEAD, POST, PUT, DELETE, PATCH, OPTIONS, TRACE, CONNECT) are recognized. Extension methods are preserved without information loss.

§Case sensitivity

HTTP methods are case-sensitive per RFC 9110 section 9.1. Method preserves the original casing.

§Validation

A valid method is a non-empty sequence of visible ASCII characters (code points 0x21–0x7E) excluding separators. This matches the token production in RFC 9110.

Implementations§

Source§

impl Method

Source

pub fn new(value: impl Into<String>) -> Result<Self, MethodError>

Create a validated method from a string.

§Errors

Returns MethodError if the string is empty or contains invalid characters.

Source

pub fn get() -> Self

Create a Method for GET.

Source

pub fn head() -> Self

Create a Method for HEAD.

Source

pub fn post() -> Self

Create a Method for POST.

Source

pub fn put() -> Self

Create a Method for PUT.

Source

pub fn delete() -> Self

Create a Method for DELETE.

Source

pub fn patch() -> Self

Create a Method for PATCH.

Source

pub fn options() -> Self

Create a Method for OPTIONS.

Source

pub fn trace() -> Self

Create a Method for TRACE.

Source

pub fn connect() -> Self

Create a Method for CONNECT.

Source

pub fn as_str(&self) -> &str

Returns the method as a string slice.

Source

pub fn is_get(&self) -> bool

Returns true if this is GET.

Source

pub fn is_head(&self) -> bool

Returns true if this is HEAD.

Source

pub fn is_safe(&self) -> bool

Returns true if the method is safe (does not modify resources).

Safe methods are GET, HEAD, OPTIONS, and TRACE per RFC 9110 section 9.2.1.

Source

pub fn is_idempotent(&self) -> bool

Returns true if the method is idempotent.

Idempotent methods are GET, HEAD, PUT, DELETE, and OPTIONS per RFC 9110 section 9.2.2. TRACE is also idempotent by definition.

Source

pub fn permits_static_resolution(&self) -> bool

Returns true if this method permits static file resolution.

The built-in static service only supports GET and HEAD. This method provides a policy helper without conflating method identity with server policy.

Trait Implementations§

Source§

impl AsRef<str> for Method

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Method

Source§

fn clone(&self) -> Method

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Method

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for Method

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Method

Source§

impl Hash for Method

Source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Method

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<&str> for Method

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<str> for Method

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Method

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.