use crate::traits;
#[derive(Debug)]
#[non_exhaustive]
pub enum Scheme<T: AsRef<str>> {
Coap,
CoapS,
Http,
HttpS,
Textual(T),
}
impl<T: AsRef<str>> traits::Scheme for Scheme<T> {
fn to_cri_id(&self) -> Option<i16> {
Some(match self {
Scheme::Coap => -1,
Scheme::CoapS => -2,
Scheme::Http => -3,
Scheme::HttpS => -4,
_ => return None,
})
}
fn to_text_scheme(&self) -> &str {
match self {
Scheme::Textual(t) => t.as_ref(),
Scheme::Coap => "coap",
Scheme::CoapS => "coaps",
Scheme::Http => "http",
Scheme::HttpS => "https",
}
}
}