#![warn(missing_docs)]
pub mod alert;
pub mod assoc;
pub mod callsign;
pub mod client;
pub mod spot;
pub mod summit;
use std::{fmt::Display, hash::Hash, str::FromStr};
use serde::{de::DeserializeOwned, Serialize};
use serde_with::{DeserializeFromStr, SerializeDisplay};
pub use crate::{
alert::Alert, callsign::Callsign, client::Client, spot::Spot, summit::Summit,
summit::SummitRestriction,
};
#[allow(missing_docs)]
pub trait Notice: Hash + Eq + DeserializeOwned + Serialize {
fn callsign(&self) -> &Callsign;
fn timestamp(&self) -> String;
fn epoch(&self) -> &str;
}
pub trait HasSummit {
fn summit_code(&self) -> String;
}
#[allow(clippy::upper_case_acronyms, missing_docs)]
#[derive(Debug, Clone, PartialEq, Eq, Hash, SerializeDisplay, DeserializeFromStr)]
pub enum Mode {
AM,
CW,
Data,
DV,
FM,
SSB,
Other,
}
impl FromStr for Mode {
type Err = std::fmt::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mode = match s.to_lowercase().as_ref() {
"am" => Mode::AM,
"cw" => Mode::CW,
"data" => Mode::Data,
"dv" => Mode::DV,
"fm" => Mode::FM,
"ssb" => Mode::SSB,
_ => Mode::Other,
};
Ok(mode)
}
}
impl Display for Mode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}