1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
use std::str::FromStr; #[derive(Clone, Debug)] pub enum HttpMethod { Get, Post, } impl Default for HttpMethod { fn default() -> HttpMethod { HttpMethod::Get } } impl FromStr for HttpMethod { type Err = failure::Error; fn from_str(s: &str) -> Result<Self, failure::Error> { match s { "get" => Ok(HttpMethod::Get), "post" => Ok(HttpMethod::Post), _ => Ok(HttpMethod::default()), } } }