pub enum Method {
Get,
Post,
Put,
Patch,
Delete,
Head,
Options,
Connect,
Trace,
Other(Bytes),
}Expand description
HTTP request method (RFC 9110 §9). Standard methods are unit variants — an
integer-discriminant compare, no allocation. A non-standard method carries
its wire bytes in Method::Other, so inbound parsing of an unknown method
never copies beyond the wire buffer it already holds (use Method::from_wire).
Construction is via From<&str> / From<&[u8]> / From<Bytes>, so builder
sites that wrote .method("GET") keep working — a standard method parses to
a unit variant with zero heap, replacing the prior Bytes::copy_from_slice.
Variants§
Get
Post
Put
Patch
Delete
Head
Options
Connect
Trace
Other(Bytes)
A non-standard method, holding its wire bytes.
Implementations§
Source§impl Method
impl Method
Sourcepub fn from_bytes(bytes: &[u8]) -> Self
pub fn from_bytes(bytes: &[u8]) -> Self
Parse from raw bytes. Methods are case-sensitive uppercase tokens
(RFC 9110 §9.1), so the match is exact. Standard methods return a unit
variant without allocating; an unknown method copies into Other.
Sourcepub fn from_wire(bytes: Bytes) -> Self
pub fn from_wire(bytes: Bytes) -> Self
Take ownership of wire Bytes: a standard method drops the bytes and
returns a unit variant; an unknown method keeps the bytes zero-copy
in Other. This is the inbound-decode boundary — no allocation beyond
the wire Bytes the caller already owns.
Sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
The method’s wire bytes. Standard methods return a 'static slice; an
Other returns its carried bytes. No allocation.
Sourcepub fn to_bytes(&self) -> Bytes
pub fn to_bytes(&self) -> Bytes
The method as Bytes for wire serialization. Standard methods are
Bytes::from_static (zero allocation); Other clones its Bytes
(a refcount bump, no copy).
Trait Implementations§
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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.