From 679f1c88ea9c56110f8f66f6f253fce30704e45e Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 14 Feb 2021 13:43:29 +0400 Subject: Changed structure of library --- spider/src/http_method.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 spider/src/http_method.rs (limited to 'spider/src/http_method.rs') diff --git a/spider/src/http_method.rs b/spider/src/http_method.rs new file mode 100644 index 0000000..b1cc884 --- /dev/null +++ b/spider/src/http_method.rs @@ -0,0 +1,28 @@ +use std::fmt; + +pub enum HttpMethod { + GET, POST +} + +impl fmt::Display for HttpMethod { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + HttpMethod::GET => write!(f, "GET"), + HttpMethod::POST => write!(f, "POST") + } + } +} + +impl HttpMethod { + pub fn parse(s: String) -> Option { + if s == "GET" { + return Some(HttpMethod::GET); + } + else if s == "POST" { + return Some(HttpMethod::POST); + } + else { + return None; + } + } +} -- cgit v1.2.3