http_type/methods/
impl.rs

1use crate::*;
2
3impl Default for Methods {
4    #[inline]
5    fn default() -> Self {
6        Self::GET
7    }
8}
9
10/// Provides utility methods for the `Methods` type.
11impl Methods {
12    /// Creates a new instance of `Methods` with the default value of `Self::GET`.
13    ///
14    /// This is a shorthand for using the `default` method.
15    #[inline]
16    pub fn new() -> Self {
17        Self::default()
18    }
19
20    /// Checks if the current method is `GET`.
21    ///
22    /// Returns `true` if the method is `GET`, otherwise returns `false`.
23    #[inline]
24    pub fn is_get(&self) -> bool {
25        self.to_owned() == Self::GET.to_owned()
26    }
27
28    /// Checks if the current method is `POST`.
29    ///
30    /// Returns `true` if the method is `POST`, otherwise returns `false`.
31    #[inline]
32    pub fn is_post(&self) -> bool {
33        self.to_owned() == Self::POST.to_owned()
34    }
35}
36
37impl Display for Methods {
38    #[inline]
39    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
40        let res: &str = match self {
41            Self::GET => GET,
42            Self::POST => POST,
43        };
44        write!(f, "{}", res)
45    }
46}