Is it possible to declare a enum from a list of struct declarations and also contain them as their variants?
Like so (unwrapped):
struct CommandA {
// --snip--
}
struct CommandB {
// --snip--
}
enum Commands {
CommandA(CommandA),
CommandB(CommandB),
}
My goal is to use structs to declare commands for a serial protocol, and not have to declare repeated types (the rest I have figured out).
I would like to do something like this:
#[derive(Command)]
#[repr(C, packed(1))]
struct CommandA {
// --snip--
}
#[derive(Command)]
#[repr(C, packed(1))]
struct CommandB {
// --snip--
}
Or something with a macro_rules also would be great.
The reason for not using a trait Command {} is because one of the protocol 'users' will be no_std (a micro controller), so I cant use Box<dyn Command> and the enum acts as 'catch-all' container for the type.