use crate::instr::Instr;
pub trait WriteCommand {
const OPCODE: Instr;
type Params: AsRef<[u8]>;
fn params(&self) -> Self::Params;
}
macro_rules! no_param_command {
($(#[$meta:meta])* $name:ident => $op:ident) => {
#[doc = concat!("`", stringify!($op), "`: command without parameters.")]
#[doc = ""]
$(#[$meta])*
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct $name;
impl WriteCommand for $name {
const OPCODE: Instr = Instr::$op;
type Params = [u8; 0];
fn params(&self) -> Self::Params { [] }
}
};
}
pub(crate) use no_param_command;