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
impl Method
Sourcepub fn new(value: impl Into<String>) -> Result<Self, MethodError>
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.
Sourcepub fn is_safe(&self) -> bool
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.
Sourcepub fn is_idempotent(&self) -> bool
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.
Sourcepub fn permits_static_resolution(&self) -> bool
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.