use crate::string::XString;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct XAttributeName {
pub name: XString,
pub kind: XAttributeKind,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum XAttributeKind {
Attribute,
Style,
}
impl XAttributeName {
pub const fn zero() -> Self {
Self {
name: XString::Str(""),
kind: XAttributeKind::Attribute,
}
}
}
impl std::fmt::Display for XAttributeName {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.kind {
XAttributeKind::Attribute => std::fmt::Display::fmt(&self.name, f),
XAttributeKind::Style => write!(f, "style::{}", self.name),
}
}
}
impl XAttributeKind {
pub fn make<T>(self, name: T) -> XAttributeName
where
T: Into<XString>,
{
XAttributeName {
name: name.into(),
kind: self,
}
}
}