pub const NEWLINE_STR: &'static str = "\r";
pub const TRUE: &'static str = "TRUE";
pub const FALSE: &'static str = "FALSE";
custom_derive! {
#[derive(Debug, PartialEq, Eq, EnumFromStr, EnumDisplay, Clone)]
pub enum ProtocolMode {
FEC,
ARQ
}
}
custom_derive! {
#[derive(Debug, PartialEq, Eq, EnumFromStr, EnumDisplay, Clone)]
pub enum CommandID {
ABORT,
AUTOBREAK,
BUFFER,
ARQBW,
ARQTIMEOUT,
ARQCALL,
BUSY,
BUSYBLOCK,
BUSYDET,
CONNECTED,
CWID,
DISCONNECT,
FAULT,
GRIDSQUARE,
INITIALIZE,
LEADER,
LISTEN,
NEWSTATE,
MYAUX,
MYCALL,
PING,
PROTOCOLMODE,
REJECTED,
SENDID,
TARGET,
TWOTONETEST,
VERSION
}
}
#[inline]
pub fn truth_str(v: bool) -> &'static str {
match v {
true => TRUE,
false => FALSE,
}
}
#[cfg(test)]
mod test {
use std::str;
use super::*;
#[test]
fn test_protocol_mode() {
assert_eq!(b"FEC", format!("{}", ProtocolMode::FEC).as_bytes());
assert_eq!(ProtocolMode::ARQ, str::parse("ARQ").unwrap());
}
#[test]
fn test_command() {
assert_eq!(
b"PROTOCOLMODE",
format!("{}", CommandID::PROTOCOLMODE).as_bytes()
);
assert_eq!(CommandID::ABORT, str::parse("ABORT").unwrap());
}
}