std.net.http.Method
Valuetype pub copy enum MethodAn HTTP request method.
Only the standard request methods defined in RFC 9112 are supported. Custom request methods aren't supported as they're virtually unused, and frankly not that useful.
Constructors
Connect
Connect()Delete
Delete()Get
Get()Head
Head()Options
Options()Post
Post()Put
Put()Trace
Trace()Static methods
parse
Show source codeHide source code
fn pub static parse[B: Bytes](input: ref B) -> Option[Method] {
method.parse(input)
}fn pub static parse[B: Bytes](input: ref B) -> Option[Method]Creates a Method from a sequence of bytes.
If the request method isn't recognized, an Option.None is returned.
Examples
import std.net.http (Method)
Method.parse('GET') # => Option.Some(Method.Get)
Method.parse('FOO') # => Option.None
Instance methods
!=
Show source codeHide source code
fn pub !=(other: ref Self) -> Bool {
!(self == other)
}fn pub !=(other: ref Self) -> BoolReturns true if self and the given object are not equal to each other.
==
Show source codeHide source code
fn pub ==(other: Method) -> Bool {
method.eq(self, other)
}fn pub ==(other: Method) -> BoolReturns true if self and the given object are equal to each other.
This operator is used to perform structural equality. This means two objects residing in different memory locations may be considered equal, provided their structure is equal. For example, two different arrays may be considered to have structural equality if they contain the exact same values.
clone
Show source codeHide source code
fn pub inline clone -> Self {
self
}fn pub inline clone -> MethodCreates a clone of self.
The returned value is an owned value that is the same type as the receiver
of this method. For example, cloning a ref Array[Int] results in a
Array[Int], not another ref Array[Int].
fmt
Show source codeHide source code
fn pub fmt(formatter: mut Formatter) {
method.format(formatter, self)
}fn pub fmt(formatter: mut Formatter)Formats self in a human-readable format for debugging purposes.
get?
Show source codeHide source code
fn pub inline get? -> Bool {
match self {
case Get -> true
case _ -> false
}
}fn pub inline get? -> BoolReturns true if self is a Method.Get.
hash
Show source codeHide source code
fn pub inline hash[H: mut + Hasher](hasher: mut H) {
method.hash(hasher, self)
}fn pub inline hash[H: mut + Hasher](hasher: mut H: mut)Writes the hash for self into the given Hasher.
safe?
Show source codeHide source code
fn pub inline safe? -> Bool {
match self {
case Get or Head or Options or Trace -> true
case _ -> false
}
}fn pub inline safe? -> BoolReturns true if self is a "safe" method (RFC 9110, section 9.2.1).
Examples
import std.net.http (Method)
Method.Get.safe? # => true
Method.Post.safe? # => false
to_string
Show source codeHide source code
fn pub to_string -> String {
method.to_string(self)
}fn pub to_string -> StringConverts self to a String.
Implemented traits
Clone
impl Clone for MethodEqual
impl Equal for MethodFormat
impl Format for MethodHash
impl Hash for MethodToString
impl ToString for Method