pub trait HttpMethodAlg {
const METHOD: HttpMethod;
}
macro_rules! http_methods {
($($declaration:ident => $marker:ident, $label:literal),+ $(,)?) => {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum HttpMethod {
$(
#[doc = concat!("Selects the `", $label, "` request method.")]
$marker,
)+
}
impl HttpMethod {
pub const ALL: &'static [Self] = &[$(Self::$marker),+];
pub const fn label(self) -> &'static str {
match self {
$(Self::$marker => $label,)+
}
}
}
$(
#[doc = concat!("Identifies a `", $label, "` endpoint declaration.")]
#[derive(Debug, Default)]
pub struct $marker;
impl HttpMethodAlg for $marker {
const METHOD: HttpMethod = HttpMethod::$marker;
}
)+
};
}
with_http_methods!(http_methods);