use crate::{Account, Category, Domain, EntityRoot, Part, Parts};
pub trait ErnComponent {
fn prefix() -> &'static str;
type NextState;
}
macro_rules! impl_ern_component {
($type:ty, $prefix:expr, $next:ty) => {
impl ErnComponent for $type {
fn prefix() -> &'static str {
$prefix
}
type NextState = $next;
}
};
}
impl ErnComponent for EntityRoot {
fn prefix() -> &'static str {
""
}
type NextState = Part;
}
impl ErnComponent for Account {
fn prefix() -> &'static str {
""
}
type NextState = EntityRoot;
}
impl_ern_component!(Domain, "ern:", Category);
impl_ern_component!(Category, "", Account);
impl_ern_component!(Part, "", Parts);
impl ErnComponent for Parts {
fn prefix() -> &'static str {
":"
}
type NextState = Parts;
}