use std::fmt::{self, Display};
use crate::format::{self, Separator};
const PREFIX: &str = "==";
const SEPARATOR: Separator = Separator::Char('=');
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
pub struct Signature(String);
impl Signature {
pub fn parse<S: AsRef<str>>(string: S) -> Option<Self> {
let string = format::slugify(string, &SEPARATOR);
(!string.is_empty()).then_some(string).map(Self)
}
}
impl Display for Signature {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}{}", PREFIX, self.0)
}
}