1#[derive(Debug, Clone, Copy)]
2pub enum Method {
3 GET,
4 POST,
5 HEAD,
6 PATCH,
7 PUT,
8 TRACE,
9 DELETE,
10 CONNECT,
11 OPTIONS,
12}
13
14impl Method {
15 pub fn as_str(&self) -> &'static str {
16 match self {
17 Method::GET => "GET",
18 Method::POST => "POST",
19 Method::HEAD => "HEAD",
20 Method::PATCH => "PATCH",
21 Method::PUT => "PUT",
22 Method::TRACE => "TRACE",
23 Method::DELETE => "DELETE",
24 Method::CONNECT => "CONNECT",
25 Method::OPTIONS => "OPTIONS",
26 }
27 }
28
29 #[cfg(target_os = "windows")]
31 pub(crate) fn as_raw_str_wide(&self) -> *const u16 {
32 let data: &[u16] = match self {
33 Method::GET => &[71, 69, 84, 0],
34 Method::POST => &[80, 79, 83, 84, 0],
35 Method::HEAD => &[72, 69, 65, 68, 0],
36 Method::PATCH => &[80, 65, 84, 67, 72, 0],
37 Method::PUT => &[80, 85, 84, 0],
38 Method::TRACE => &[84, 82, 65, 67, 69, 0],
39 Method::DELETE => &[68, 69, 76, 69, 84, 69, 0],
40 Method::CONNECT => &[67, 79, 78, 78, 69, 67, 84, 0],
41 Method::OPTIONS => &[79, 80, 84, 73, 79, 78, 83, 0],
42 };
43 data.as_ptr()
44 }
45}