[−][src]Trait imperative_rs::InstructionSet
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
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
.
fn encode(&self, buf: &mut [u8]) -> Result<usize, EncodeError>
Used to encode instructions into a byte buffer. The buffer needs to be provided as a
&mut [u8]
. The function returns a result containing either the number of bytes read or an
EncodeError