#[non_exhaustive]pub enum Method {
GET,
HEAD,
POST,
PUT,
DELETE,
}Expand description
A HTTP method that is provided by the client
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
GET
The GET method requests a representation of the specified resource.
Requests using GET should only retrieve data.
HEAD
The HEAD method asks for a response identical to a GET request, but without the response body.
POST
The POST method submits an entity to the specified resource, often causing a change in state or side effects on the server.
PUT
The PUT method replaces all current representations of the target resource with the request payload.
DELETE
The DELETE method deletes the specified resource.
Implementations§
Source§impl Method
impl Method
Sourcepub fn new<S>(method: S) -> Option<Self>
pub fn new<S>(method: S) -> Option<Self>
Returns an Option containing Method by passing a &str or String corresponding to a HTTP method
If the method provided is a valid HTTP method, this function will evaluate to Some containing Self
If the method provided isn’t valid or implemented yet, this function will return None
§Example
fn main() {
// Create a new HTTP Method instance (in our case, Method::GET)
let method: Option<Method> = Method::new("GET");
assert_eq!(method, Some(Method::GET));
}