#[derive(Debug, Clone, Hash, Eq, PartialEq)] pub enum Method { Get, Head, Post, Put, Delete, Connect, Options, Trace, Patch } impl Method { pub fn serialize(string: &str) -> Option { match string { "GET" => Some(Self::Get), "HEAD" => Some(Self::Head), "POST" => Some(Self::Post), "PUT" => Some(Self::Put), "DELETE" => Some(Self::Delete), "CONNECT" => Some(Self::Connect), "OPTIONS" => Some(Self::Options), "TRACE" => Some(Self::Trace), "PATCH" => Some(Self::Patch), _ => None } } pub fn deserialize(&self) -> &str { match self { Method::Get => "GET", Method::Head => "HEAD", Method::Post => "POST", Method::Put => "PUT", Method::Delete => "DELETE", Method::Connect => "CONNECT", Method::Options => "OPTIONS", Method::Trace => "TRACE", Method::Patch => "PATCH", } } }