use console::network::prelude::*;
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub enum Opcode {
Assert(&'static str),
Async,
Call(&'static str),
Cast(&'static str),
Command(&'static str),
Commit(&'static str),
Deserialize(&'static str),
ECDSA(&'static str),
GetRecordDynamic(&'static str),
Hash(&'static str),
Is(&'static str),
Literal(&'static str),
Serialize(&'static str),
Sign(&'static str),
Snark(&'static str),
}
impl Deref for Opcode {
type Target = &'static str;
fn deref(&self) -> &Self::Target {
match self {
Opcode::Assert(opcode) => opcode,
Opcode::Async => &"async",
Opcode::Call(opcode) => opcode,
Opcode::Cast(opcode) => opcode,
Opcode::Command(opcode) => opcode,
Opcode::Commit(opcode) => opcode,
Opcode::Deserialize(opcode) => opcode,
Opcode::ECDSA(opcode) => opcode,
Opcode::GetRecordDynamic(opcode) => opcode,
Opcode::Hash(opcode) => opcode,
Opcode::Is(opcode) => opcode,
Opcode::Literal(opcode) => opcode,
Opcode::Serialize(opcode) => opcode,
Opcode::Sign(opcode) => opcode,
Opcode::Snark(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::Async => write!(f, "{}", self.deref()),
Self::Call(opcode) => write!(f, "{opcode}"),
Self::Cast(opcode) => write!(f, "{opcode}"),
Self::Command(opcode) => write!(f, "{opcode}"),
Self::Commit(opcode) => write!(f, "{opcode}"),
Self::Deserialize(opcode) => write!(f, "{opcode}"),
Self::ECDSA(opcode) => write!(f, "{opcode}"),
Self::GetRecordDynamic(opcode) => write!(f, "{opcode}"),
Self::Hash(opcode) => write!(f, "{opcode}"),
Self::Is(opcode) => write!(f, "{opcode}"),
Self::Literal(opcode) => write!(f, "{opcode}"),
Self::Serialize(opcode) => write!(f, "{opcode}"),
Self::Sign(opcode) => write!(f, "{opcode}"),
Self::Snark(opcode) => write!(f, "{opcode}"),
}
}
}