Skip to main content

rcus_core/
action.rs

1use std::fmt;
2
3#[derive(Clone, Debug, PartialEq, Eq, Hash)]
4pub struct Action {
5    name: String,
6}
7
8impl Action {
9    pub fn new(name: impl Into<String>) -> Self {
10        Self { name: name.into() }
11    }
12
13    pub fn name(&self) -> &str {
14        &self.name
15    }
16}
17
18#[derive(Debug, Clone, PartialEq, Eq)]
19pub enum ActionError {
20    Unknown(String),
21}
22
23impl fmt::Display for ActionError {
24    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25        match self {
26            Self::Unknown(name) => write!(f, "unknown action: {name}"),
27        }
28    }
29}
30
31impl std::error::Error for ActionError {}