1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use std::{
borrow::Cow,
fmt::{Display, Write},
};
use serde::{Deserialize, Serialize};
pub trait Action: Send + Sync {
fn name(&self) -> ActionName;
}
impl Action for () {
fn name(&self) -> ActionName {
ActionName::default()
}
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
#[allow(clippy::module_name_repetitions)]
pub struct ActionName(pub Vec<Cow<'static, str>>);
impl Display for ActionName {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for (index, name) in self.0.iter().enumerate() {
if index > 0 {
f.write_char('.')?;
}
name.fmt(f)?;
}
Ok(())
}
}
pub use actionable_macros::Action;