expression

Method: parse a case-sensitive HTTP method

HTTP method tokens are case-sensitive. The crate can represent extension methods; parsing a token does not mean your application supports it. External crate example; constructs data in memory, does not send requests. Expected stdout (not executed): true false true Common mistake: Normalizing every method token to uppercase before checking its meaning.

Formal Syntax & Structure

rust syntaxrust
http::Method::from_bytes(bytes) -> Result<Method, InvalidMethod>

Working Example

Example Snippetrust
fn main() {    use http::Method;    let method = Method::from_bytes(b"GET").unwrap();    let lower = Method::from_bytes(b"get").unwrap();    println!("{} {}", method == Method::GET, lower == Method::GET);    println!("{}", Method::from_bytes(b"bad method").is_err());}
Rust Reference