use std::str::FromStr;
#[allow(missing_debug_implementations, missing_copy_implementations)]
#[must_use]
pub enum OutputSignal {
Output,
OutputDone,
Done,
}
impl OutputSignal {
#[must_use]
#[doc(hidden)]
pub fn as_str(&self) -> &'static str {
match self {
OutputSignal::Output => "1",
OutputSignal::OutputDone => "2",
OutputSignal::Done => "3",
}
}
}
impl FromStr for OutputSignal {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
let result = match s {
"1" => OutputSignal::Output,
"2" => OutputSignal::OutputDone,
"3" => OutputSignal::Done,
_ => return Err(()),
};
Ok(result)
}
}
#[allow(missing_debug_implementations, missing_copy_implementations)]
#[must_use]
pub enum HostCommand {
Output,
LinkCall,
Log,
}
impl HostCommand {
#[must_use]
#[doc(hidden)]
pub fn as_str(&self) -> &'static str {
match self {
HostCommand::Output => "0",
HostCommand::LinkCall => "1",
HostCommand::Log => "2",
}
}
}
impl FromStr for HostCommand {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
let result = match s {
"0" => HostCommand::Output,
"1" => HostCommand::LinkCall,
"2" => HostCommand::Log,
_ => return Err(()),
};
Ok(result)
}
}
#[allow(missing_debug_implementations, missing_copy_implementations)]
#[must_use]
pub enum LogLevel {
Info,
Error,
Warn,
Debug,
Trace,
Mark,
}
impl LogLevel {
#[must_use]
#[doc(hidden)]
pub fn as_str(&self) -> &'static str {
match self {
LogLevel::Info => "0",
LogLevel::Error => "1",
LogLevel::Warn => "2",
LogLevel::Debug => "3",
LogLevel::Trace => "4",
LogLevel::Mark => "5",
}
}
}
impl FromStr for LogLevel {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
let result = match s {
"0" => LogLevel::Info,
"1" => LogLevel::Error,
"2" => LogLevel::Warn,
"3" => LogLevel::Debug,
"4" => LogLevel::Trace,
"5" => LogLevel::Mark,
_ => return Err(()),
};
Ok(result)
}
}