pub mod snap_token;
use std::{fmt::Display, str::FromStr};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Serialize, Deserialize, Clone)]
pub struct Pssid(pub Uuid);
impl Default for Pssid {
fn default() -> Self {
Self::new()
}
}
impl Pssid {
pub fn new() -> Self {
Self(Uuid::new_v4())
}
}
impl FromStr for Pssid {
type Err = std::io::Error;
fn from_str(value: &str) -> Result<Self, Self::Err> {
match Uuid::parse_str(value) {
Ok(uuid) => Ok(Pssid(uuid)),
Err(_) => {
Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"Invalid PSSID",
))
}
}
}
}
impl From<Pssid> for String {
fn from(pssid: Pssid) -> Self {
pssid.0.to_string()
}
}
impl Display for Pssid {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0)
}
}