pub enum Method {
Get,
Head,
Post,
Put,
Delete,
Connect,
Options,
Trace,
Patch,
Query,
Other(ByteStr),
}Expand description
An HTTP request method.
Well-known methods are unit variants, so dispatch is a discriminant
comparison rather than a string comparison. Unrecognized methods carry a
ByteStr slice of the read buffer.
Variants§
Get
GET
Head
HEAD
Post
POST
Put
PUT
Delete
DELETE
Connect
CONNECT
Options
OPTIONS
Trace
TRACE
Patch
PATCH
Query
QUERY — a safe method that carries a request body.
Other(ByteStr)
Any other valid method token.
Implementations§
Source§impl Method
impl Method
Sourcepub fn from_bytes(token: &[u8]) -> Option<Method>
pub fn from_bytes(token: &[u8]) -> Option<Method>
Match a method token against the well-known set.
Returns None when the token is not well-known; the caller then builds
Method::Other from the read buffer. Keeping Bytes out of this
signature is what makes the function trivially unit-testable.
Methods are case-sensitive (RFC 9110 section 9.1), so this compares exactly. Dispatching on length first means most calls do one integer comparison and one short memcmp.
Sourcepub fn is_safe(&self) -> bool
pub fn is_safe(&self) -> bool
Whether this method is safe per RFC 9110 section 9.2.1.
Unrecognized methods are conservatively treated as unsafe.
Sourcepub fn expects_response_body(&self) -> bool
pub fn expects_response_body(&self) -> bool
Whether a response to this method may carry a body.
HEAD responses carry headers only, including the Content-Length the
equivalent GET would have produced (RFC 9112 section 6.3).
Trait Implementations§
impl Eq for Method
Source§impl From<&str> for Method
impl From<&str> for Method
Source§fn from(token: &str) -> Method
fn from(token: &str) -> Method
Parse a method token, falling back to Method::Other.
Infallible on purpose: this exists so armature-core’s constructors can
take impl Into<Method> and keep every existing HttpRequest::new("GET")
call site compiling. An invalid token is not rejected here — it is carried
as Other and answered by routing, which is where a 405 belongs.
Source§impl From<HttpMethod> for Method
impl From<HttpMethod> for Method
Source§fn from(m: HttpMethod) -> Self
fn from(m: HttpMethod) -> Self
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 UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<R, D> DepsPresent<D> for R
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Injectable for T
impl<T> Injectable for T
Source§fn type_id_of() -> TypeIdwhere
Self: Sized,
fn type_id_of() -> TypeIdwhere
Self: Sized,
Source§fn type_name_of() -> &'static strwhere
Self: Sized,
fn type_name_of() -> &'static strwhere
Self: Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Provider for Twhere
T: Injectable,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more