pub trait BytecodeStream: Copy {
type Error;
// Required methods
fn unexpected_eof(&self) -> Self::Error;
fn invalid_opcode(&self, code: u8) -> Self::Error;
fn invalid_extended_opcode(&self, code: u16) -> Self::Error;
fn invalid_reg(&self, reg: u8) -> Self::Error;
fn read<const N: usize>(&mut self) -> Result<[u8; N], Self::Error>;
}
Available on crate feature
decode
only.Expand description
An abstraction over any kind of bytecode stream.
There are two primary implementations:
-
SafeBytecodeStream
: A thin wrapper around an index into a&[u8]
. This implementation is 100% safe code. -
UnsafeBytecodeStream
: A thin wrapper over a raw pointer. This implementation is wildly unsafe and will result in memory unsafety and other terrors when given invalid bytecode, or even valid bytecode encoding a program that itself does not preserve memory safety.
Required Associated Types§
Required Methods§
sourcefn unexpected_eof(&self) -> Self::Error
fn unexpected_eof(&self) -> Self::Error
Create an “unexpected end-of-stream” error at the current position.
sourcefn invalid_opcode(&self, code: u8) -> Self::Error
fn invalid_opcode(&self, code: u8) -> Self::Error
Create an “invalid opcode” error at the current position.
sourcefn invalid_extended_opcode(&self, code: u16) -> Self::Error
fn invalid_extended_opcode(&self, code: u16) -> Self::Error
Create an “invalid extended opcode” error at the current position.
sourcefn invalid_reg(&self, reg: u8) -> Self::Error
fn invalid_reg(&self, reg: u8) -> Self::Error
Create an “invalid register” error at the current position.
Object Safety§
This trait is not object safe.