use console::network::prelude::*;
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub enum Opcode {
Assert(&'static str),
Call,
Cast,
Command(&'static str),
Commit(&'static str),
Finalize(&'static str),
Hash(&'static str),
Is(&'static str),
Literal(&'static str),
}
impl Deref for Opcode {
type Target = &'static str;
fn deref(&self) -> &Self::Target {
match self {
Opcode::Assert(opcode) => opcode,
Opcode::Call => &"call",
Opcode::Cast => &"cast",
Opcode::Command(opcode) => opcode,
Opcode::Commit(opcode) => opcode,
Opcode::Finalize(opcode) => opcode,
Opcode::Hash(opcode) => opcode,
Opcode::Is(opcode) => opcode,
Opcode::Literal(opcode) => opcode,
}
}
}
impl Debug for Opcode {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
Display::fmt(self, f)
}
}
impl Display for Opcode {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self {
Self::Assert(opcode) => write!(f, "{opcode}"),
Self::Call => write!(f, "{}", self.deref()),
Self::Cast => write!(f, "{}", self.deref()),
Self::Command(opcode) => write!(f, "{opcode}"),
Self::Commit(opcode) => write!(f, "{opcode}"),
Self::Finalize(opcode) => write!(f, "{opcode}"),
Self::Hash(opcode) => write!(f, "{opcode}"),
Self::Is(opcode) => write!(f, "{opcode}"),
Self::Literal(opcode) => write!(f, "{opcode}"),
}
}
}