pub trait InstructionSet: Sized {
// Required methods
fn decode(mem: &[u8]) -> Result<(usize, Self), DecodeError>;
fn encode(&self, buf: &mut [u8]) -> Result<usize, EncodeError>;
}
Expand description
This trait
defines an instruction set. It provides functionality to decode from or encode to
opcodes. It can be autoderived for suitable enum
s by a procedual macro provided by this crate.
Required Methods§
Sourcefn decode(mem: &[u8]) -> Result<(usize, Self), DecodeError>
fn decode(mem: &[u8]) -> Result<(usize, Self), DecodeError>
Used to decode an instruction (i.e. Self
) from a byte buffer. The buffer needs to be
provided as a &[u8]
and the function returns a result containing either a tuple containing
the number of bytes written and the resulting instruction or an DecodeError
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.