use std::str::FromStr;
#[cfg(feature = "derive")]
pub use fav_derive::Attr;
#[allow(missing_docs)]
#[derive(Debug, PartialEq)]
pub enum Id {
I64(i64),
I32(i32),
String(String),
}
impl From<i64> for Id {
fn from(id: i64) -> Self {
Id::I64(id)
}
}
impl From<i32> for Id {
fn from(id: i32) -> Self {
Id::I32(id)
}
}
impl FromStr for Id {
type Err = std::convert::Infallible;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.parse::<i64>() {
Ok(id) => Ok(Id::I64(id)),
Err(_) => Ok(Id::String(s.to_owned())),
}
}
}
pub trait Attr {
fn id(&self) -> Id;
fn name(&self) -> &str;
}