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>;
}
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.
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.