moduforge_macros/
command.rs1#[macro_export]
2macro_rules! impl_command {
3 ($name:ident, $execute_fn:expr) => {
4 #[derive(Debug)]
5 pub struct $name;
6
7 #[async_trait]
8 impl Command for $name {
9 async fn execute(
10 &self,
11 tr: &mut Transaction,
12 ) -> TransformResult<()> {
13 $execute_fn(tr).await
14 }
15
16 fn name(&self) -> String {
17 stringify!($name).to_string()
18 }
19 }
20 };
21 ($name:ident, $execute_fn:expr, $name_str:expr) => {
22 #[derive(Debug)]
23 pub struct $name;
24
25 #[async_trait]
26 impl Command for $name {
27 async fn execute(
28 &self,
29 tr: &mut Transaction,
30 ) -> TransformResult<()> {
31 $execute_fn(tr).await
32 }
33
34 fn name(&self) -> String {
35 $name_str.to_string()
36 }
37 }
38 };
39}