1use crate::instr::Instr;
2
3pub trait WriteCommand {
5 const OPCODE: Instr;
7 type Params: AsRef<[u8]>;
9 fn params(&self) -> Self::Params;
11}
12
13macro_rules! no_param_command {
14 ($(#[$meta:meta])* $name:ident => $op:ident) => {
15 #[doc = concat!("`", stringify!($op), "`: command without parameters.")]
16 #[doc = ""]
17 $(#[$meta])*
18 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
19 pub struct $name;
20 impl WriteCommand for $name {
21 const OPCODE: Instr = Instr::$op;
22 type Params = [u8; 0];
23 fn params(&self) -> Self::Params { [] }
24 }
25 };
26}
27
28pub(crate) use no_param_command;