rustify/
enums.rs

1//! Contains common enums used across the crate
2
3/// Represents a HTTP request method
4#[derive(Clone, Debug)]
5pub enum RequestMethod {
6    CONNECT,
7    DELETE,
8    GET,
9    HEAD,
10    LIST,
11    OPTIONS,
12    PATCH,
13    POST,
14    PUT,
15    TRACE,
16}
17
18#[allow(clippy::from_over_into)]
19impl Into<http::Method> for RequestMethod {
20    fn into(self) -> http::Method {
21        match self {
22            RequestMethod::CONNECT => http::Method::CONNECT,
23            RequestMethod::DELETE => http::Method::DELETE,
24            RequestMethod::GET => http::Method::GET,
25            RequestMethod::HEAD => http::Method::HEAD,
26            RequestMethod::LIST => http::Method::from_bytes("LIST".as_bytes()).unwrap(),
27            RequestMethod::OPTIONS => http::Method::OPTIONS,
28            RequestMethod::PATCH => http::Method::PATCH,
29            RequestMethod::POST => http::Method::POST,
30            RequestMethod::PUT => http::Method::PUT,
31            RequestMethod::TRACE => http::Method::TRACE,
32        }
33    }
34}
35
36/// Represents the type of a HTTP request body
37#[derive(Clone, Debug)]
38pub enum RequestType {
39    JSON,
40}
41
42/// Represents the type of a HTTP response body
43#[derive(Clone, Debug)]
44pub enum ResponseType {
45    JSON,
46}