pub mod capabilities;
pub mod features;
use std::{
convert::Infallible,
fmt::{self, Display, Formatter},
str::FromStr,
};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Protocol {
Monitor,
Display,
Unknown(String),
}
impl<'a> From<&'a str> for Protocol {
fn from(s: &'a str) -> Self {
match s {
"monitor" => Protocol::Monitor,
"display" => Protocol::Display,
s => Protocol::Unknown(s.into()),
}
}
}
impl Display for Protocol {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
Display::fmt(
match *self {
Protocol::Monitor => "monitor",
Protocol::Display => "display",
Protocol::Unknown(ref s) => s,
},
f,
)
}
}
impl FromStr for Protocol {
type Err = Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(s.into())
}
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum DisplayTechnology {
Crt,
Lcd,
Led,
Unknown(String),
}
impl<'a> From<&'a str> for DisplayTechnology {
fn from(s: &'a str) -> Self {
match s {
s if s.eq_ignore_ascii_case("crt") => DisplayTechnology::Crt,
s if s.eq_ignore_ascii_case("lcd") => DisplayTechnology::Lcd,
s if s.eq_ignore_ascii_case("led") => DisplayTechnology::Led,
s => DisplayTechnology::Unknown(s.into()),
}
}
}
impl Display for DisplayTechnology {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
Display::fmt(
match *self {
DisplayTechnology::Crt => "crt",
DisplayTechnology::Lcd => "lcd",
DisplayTechnology::Led => "led",
DisplayTechnology::Unknown(ref s) => s,
},
f,
)
}
}
impl FromStr for DisplayTechnology {
type Err = Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(s.into())
}
}
#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Version {
pub major: u8,
pub minor: u8,
}
impl Version {
pub fn new(major: u8, minor: u8) -> Self {
Version { major, minor }
}
}
impl Display for Version {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{}.{}", self.major, self.minor)
}
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct UnknownTag {
pub name: String,
pub data: UnknownData,
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum UnknownData {
String(String),
StringBytes(Vec<u8>),
Binary(Vec<u8>),
}