macro_rules! operation_enum {
(
$(#[$meta:meta])*
$vis:vis enum $name:ident {
$($(#[$variant_meta:meta])* $variant:ident($inner:ty),)+
}
) => { ... };
}Expand description
Define the enum that wraps the operations of each resource.
Each variant holds the operation type of one resource. The enum gets a
Display that shows the inner operation and a From for each inner type.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Rename;
impl std::fmt::Display for Rename {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str("repository")
}
}
ephemeris_forge::operation_enum! {
/// One write.
pub enum Operation {
/// A write to the repository.
Repository(Rename),
}
}
assert_eq!(Operation::from(Rename).to_string(), "repository");