[][src]Enum imperative_rs::DecodeError

pub enum DecodeError {
    UnknownOpcode,
    UnexpectedEOF,
    Overflow,
}

This type is returned by fn InstructionSet::decode(...) in case no instruction could be decoded.

Variants

UnknownOpcode

This variant is emitted if the slice contains no known opcode.

UnexpectedEOF

Is emitted if the slice ended before a complete opcode could be found. Extending the end of the slice could lead to successful decoding.

Overflow

Is emitted if the opcode encodes a variable that is too big for the corresponding variable. An example would be if the opcode contains a 9 bit variable that is put into a u8 during decoding.

use imperative::{InstructionSet, DecodeError};
#[derive(InstructionSet)]
enum Is {
    #[opcode = "0b0000000v_vvvvvvvv"]
    A{v:u8},
}

fn main () {
    let mem = [0b00000001, 0b11111111];
    let instr = Is::decode(&mem);
    assert_eq!(DecodeError::Overflow, instr); //trying to cast 256 into an u8
}

Trait Implementations

impl Debug for DecodeError[src]

impl PartialEq<DecodeError> for DecodeError[src]

impl PartialOrd<DecodeError> for DecodeError[src]

impl StructuralPartialEq for DecodeError[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.