method
import std::net::http::method; · source
Types
Method
type enum Method {
Get;
Head;
Post;
Put;
Delete;
Connect;
Options;
Trace;
Patch;
}
implement enum Method {
as_str(&this) -> Str;
static parse(source: Str) -> Result<Method, ConversionError>;
static parse_opt(source: Str) -> Option<Method>;
}
The standard verbs. as_str gives the wire spelling; parse and parse_opt read one — parse reports an unknown verb as a ConversionError, parse_opt as None.
Variants
| Variant |
|---|
Get |
Head |
Post |
Put |
Delete |
Connect |
Options |
Trace |
Patch |
Constructors
static parse(source: Str) -> Result<Method, ConversionError>;
static parse(source: Str) -> Result<Method, ConversionError>;Parse the uppercase wire form. Returns Err(ConversionError) on unknown methods rather than inventing a variant; the caller decides whether to 405 or to treat as a bad request. The error is describable/printable - consistent with the other stdlib parsers. Use parse_opt for the detail-free variant.
static parse_opt(source: Str) -> Option<Method>;
static parse_opt(source: Str) -> Option<Method>;Detail-free variant of parse: None on unknown methods.
Methods
as_str(&this) -> Str;
as_str(&this) -> Str;Uppercase wire form.
type struct Name { ... }
type enum Name { ... }
type trait Name { ... }
type union Name { ... }Begins a type declaration; the keyword that follows says which kind. On its own, type Name = Existing; declares an alias.
type enum Name {
Unit,
Payload(T),
Named { x: i32 },
}An algebraic data type. Variants may be bare or carry a tuple or struct payload, and a match on an enum must cover every variant. Name::Variant names a variant; methods are added with implement enum Name { ... }.
type enum Method {
Get;
Head;
Post;
Put;
Delete;
Connect;
Options;
Trace;
Patch;
}HTTP method.
Method::GetMethod::HeadMethod::PostMethod::PutMethod::DeleteMethod::ConnectMethod::OptionsMethod::TraceMethod::Patchimplement struct Name { ... }
implement trait Trait for Type { ... }
implement u64 { ... }Adds methods to a type outside its declaration. implement struct T (or enum, or a bare primitive) opens an inherent block; implement trait Tr for T supplies a trait's methods for one type. Resolution is at compile time - no dynamic dispatch.
implement enum Name { ... }Names the enum an inherent block extends - the only way to give an enum methods.
language referencetype enum Method {
Get;
Head;
Post;
Put;
Delete;
Connect;
Options;
Trace;
Patch;
}HTTP method.
std::net::http::methodMethod::as_str(&this) -> StrUppercase wire form.
&this
mut &this
thisThe receiver of a method. Its first parameter declares how the method takes it: &this borrows read-only, mut &this borrows exclusively, and this / mut this move the value in and consume it. In the body, this.field reaches the members.
type struct Str {
bytes: u8*;
length: u64;
}Str: a borrowed UTF-8 string slice.
std::collections::strstatic name(param: Type) -> Ret { ... }A method that belongs to the type rather than an instance, called as Type::name(..). For structs, static new(..) returning a struct literal is the idiomatic constructor.
static Method::parse(source: Str) -> Result<Method, ConversionError>Parse the uppercase wire form. Returns Err(ConversionError) on unknown methods rather than inventing a variant; the caller decides whether to 405 or to treat as a bad request. The error is describable/printable - consistent with the other stdlib parsers. Use parse_opt for the detail-free variant.
(parameter) source: Strtype struct ConversionError {
reason: string;
}What went wrong in a TryFrom / TryInto. Carries a short static message describing the failure; richer diagnostics are a caller concern.
static Method::parse_opt(source: Str) -> Option<Method>Detail-free variant of parse: None on unknown methods.
import a::b;
import a::b::{ X, Y };
import a::b as c;
import a::b::*;Brings a module, or selected items from it, into scope. One path per declaration: use the brace form for several items, as to alias, and * for everything public (prefer the brace form; wildcards invite name collisions).
static Method::parse(source: Str) -> Result<Method, ConversionError>Parse the uppercase wire form. Returns Err(ConversionError) on unknown methods rather than inventing a variant; the caller decides whether to 405 or to treat as a bad request. The error is describable/printable - consistent with the other stdlib parsers. Use parse_opt for the detail-free variant.
static Method::parse_opt(source: Str) -> Option<Method>Detail-free variant of parse: None on unknown methods.
Option::NoneMethod::GetMethod::HeadMethod::PostMethod::PutMethod::DeleteMethod::ConnectMethod::OptionsMethod::TraceMethod::PatchResult::Err(E)