#[non_exhaustive]pub enum InstError {
UnknownOpcode(u8),
InvalidOperand {
opcode: Opcode,
field: &'static str,
},
NonCanonical(Opcode),
}Expand description
Why eight bytes are not an instruction.
§Examples
use bytecode_lang::{Inst, InstError, Opcode};
assert_eq!(Inst::from_bytes([0xff, 0, 0, 0, 0, 0, 0, 0]), Err(InstError::UnknownOpcode(0xff)));
// `nop` with a non-zero unused byte has two encodings otherwise, so it is refused.
assert_eq!(Inst::from_bytes([0x00, 1, 0, 0, 0, 0, 0, 0]), Err(InstError::NonCanonical(Opcode::Nop)));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
UnknownOpcode(u8)
The opcode byte names no instruction.
InvalidOperand
A modifier field holds a value its type does not define (for example an integer type code above 7, or a boolean above 1).
NonCanonical(Opcode)
A byte the instruction does not use is not zero.
Trait Implementations§
impl Copy for InstError
impl Eq for InstError
Source§impl Error for InstError
impl Error for InstError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
impl StructuralPartialEq for InstError
Auto Trait Implementations§
impl Freeze for InstError
impl RefUnwindSafe for InstError
impl Send for InstError
impl Sync for InstError
impl Unpin for InstError
impl UnsafeUnpin for InstError
impl UnwindSafe for InstError
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