pub enum OpCode {
Known(Mnemonic),
Unknown(u8),
}Expand description
EVM operation code.
Variants§
Known(Mnemonic)
A known opcode represented as a mnemonic.
Unknown(u8)
An unknown opcode represented as a byte.
Implementations§
Source§impl OpCode
impl OpCode
Sourcepub const fn is_unknown(&self) -> bool
pub const fn is_unknown(&self) -> bool
Returns true if the enum is OpCode::Unknown otherwise false
Source§impl OpCode
impl OpCode
Sourcepub const fn from_byte(byte: u8) -> Self
pub const fn from_byte(byte: u8) -> Self
Convert a byte into an OpCode, returning OpCode::Unknown if no known mnemonic
exists.
§Example
assert_eq!(OpCode::from_byte(0x5A), OpCode::Known(Mnemonic::GAS));
assert_eq!(OpCode::from_byte(0xF), OpCode::Unknown(0xF));Sourcepub const fn try_from_byte(byte: u8) -> Option<Self>
pub const fn try_from_byte(byte: u8) -> Option<Self>
Try to convert a byte into a known mnemonic.
Returns None if the opcode is unknown.
§Example
assert_eq!(OpCode::try_from_byte(0x5A), Some(OpCode::Known(Mnemonic::GAS)));
assert_eq!(OpCode::try_from_byte(0xF), None);Sourcepub const fn into_byte(self) -> u8
pub const fn into_byte(self) -> u8
Convert opcode into a byte.
§Example
assert_eq!(OpCode::Known(Mnemonic::GAS).into_byte(), 0x5A);
assert_eq!(OpCode::Unknown(0xF).into_byte(), 0xF);Sourcepub const fn is_push(&self) -> bool
pub const fn is_push(&self) -> bool
Returns a value signifying whether this opcode is of the type PUSHx.
§Example
assert_eq!(OpCode::Known(Mnemonic::PUSH7).is_push(), true);
assert_eq!(OpCode::Known(Mnemonic::GAS).is_push(), false);Sourcepub const fn is_dup(&self) -> bool
pub const fn is_dup(&self) -> bool
Returns a value signifying whether this opcode is of the type DUPx.
§Example
assert_eq!(OpCode::Known(Mnemonic::DUP2).is_dup(), true);
assert_eq!(OpCode::Known(Mnemonic::GAS).is_dup(), false);Sourcepub const fn is_swap(&self) -> bool
pub const fn is_swap(&self) -> bool
Returns a value signifying whether this opcode is of the type SWAPx.
§Example
assert_eq!(OpCode::Known(Mnemonic::SWAP2).is_swap(), true);
assert_eq!(OpCode::Known(Mnemonic::GAS).is_swap(), false);Sourcepub const fn is_log(&self) -> bool
pub const fn is_log(&self) -> bool
Returns a value signifying whether this opcode is of the type LOGx.
§Example
assert_eq!(OpCode::Known(Mnemonic::LOG2).is_log(), true);
assert_eq!(OpCode::Known(Mnemonic::GAS).is_log(), false);Sourcepub const fn is_terminator(&self) -> bool
pub const fn is_terminator(&self) -> bool
Trait Implementations§
Source§impl Ord for OpCode
impl Ord for OpCode
Source§impl PartialOrd<Mnemonic> for OpCode
impl PartialOrd<Mnemonic> for OpCode
Source§impl PartialOrd<OpCode> for Mnemonic
impl PartialOrd<OpCode> for Mnemonic
Source§impl PartialOrd<u8> for OpCode
impl PartialOrd<u8> for OpCode
Source§impl PartialOrd for OpCode
impl PartialOrd for OpCode
impl Copy for OpCode
impl Eq for OpCode
impl StructuralPartialEq for OpCode
Auto Trait Implementations§
impl Freeze for OpCode
impl RefUnwindSafe for OpCode
impl Send for OpCode
impl Sync for OpCode
impl Unpin for OpCode
impl UnwindSafe for OpCode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more