acton_ern/traits/
ern_component.rs1use crate::{Account, Category, Domain, EntityRoot, Part, Parts};
2
3pub trait ErnComponent {
5 fn prefix() -> &'static str;
7 type NextState;
9}
10
11macro_rules! impl_ern_component {
12 ($type:ty, $prefix:expr, $next:ty) => {
13 impl ErnComponent for $type {
14 fn prefix() -> &'static str {
15 $prefix
16 }
17 type NextState = $next;
18 }
19 };
20}
21impl ErnComponent for EntityRoot {
22 fn prefix() -> &'static str {
23 ""
24 }
25 type NextState = Part;
26}
27
28impl ErnComponent for Account {
29 fn prefix() -> &'static str {
30 ""
31 }
32 type NextState = EntityRoot;
33}
34
35impl_ern_component!(Domain, "ern:", Category);
36impl_ern_component!(Category, "", Account);
37impl_ern_component!(Part, "", Parts);
38
39impl ErnComponent for Parts {
41 fn prefix() -> &'static str {
42 ":"
43 }
44 type NextState = Parts;
45}