pub trait BytecodeRead<Id>where
Id: SiteId,{
Show 18 methods
// Required methods
fn pos(&self) -> u16;
fn seek(&mut self, byte_pos: u16) -> Result<u16, CodeEofError>;
fn is_eof(&self) -> bool;
fn peek_byte(&self) -> Result<u8, CodeEofError>;
fn read_1bit(&mut self) -> Result<u1, CodeEofError>;
fn read_2bits(&mut self) -> Result<u2, CodeEofError>;
fn read_3bits(&mut self) -> Result<u3, CodeEofError>;
fn read_4bits(&mut self) -> Result<u4, CodeEofError>;
fn read_5bits(&mut self) -> Result<u5, CodeEofError>;
fn read_6bits(&mut self) -> Result<u6, CodeEofError>;
fn read_7bits(&mut self) -> Result<u7, CodeEofError>;
fn read_byte(&mut self) -> Result<u8, CodeEofError>;
fn read_word(&mut self) -> Result<u16, CodeEofError>;
fn read_fixed<N, const LEN: usize>(
&mut self,
f: impl FnOnce([u8; LEN]) -> N,
) -> Result<N, CodeEofError>;
fn read_bytes(
&mut self,
) -> Result<(Confined<Vec<u8>, amplify::::collection::confinement::SmallBlob::{constant#0}, amplify::::collection::confinement::SmallBlob::{constant#1}>, bool), CodeEofError>;
fn read_ref(&mut self) -> Result<Id, CodeEofError>;
fn check_aligned(&self);
// Provided method
fn read_bool(&mut self) -> Result<bool, CodeEofError> { ... }
}
Expand description
Reader from a bytecode for instruction deserialization.
Required Methods§
Sourcefn pos(&self) -> u16
fn pos(&self) -> u16
Return the current byte offset of the cursor. Does not account for bits.
If the position is exactly at EOF, returns None
.
Sourcefn seek(&mut self, byte_pos: u16) -> Result<u16, CodeEofError>
fn seek(&mut self, byte_pos: u16) -> Result<u16, CodeEofError>
Set the current cursor byte offset to the provided value if it is less than the underlying buffer length.
§Returns
Previous position.
Sourcefn peek_byte(&self) -> Result<u8, CodeEofError>
fn peek_byte(&self) -> Result<u8, CodeEofError>
Peek a single byte without moving cursor.
Sourcefn read_1bit(&mut self) -> Result<u1, CodeEofError>
fn read_1bit(&mut self) -> Result<u1, CodeEofError>
Read single bit.
Sourcefn read_2bits(&mut self) -> Result<u2, CodeEofError>
fn read_2bits(&mut self) -> Result<u2, CodeEofError>
Read two bits.
Sourcefn read_3bits(&mut self) -> Result<u3, CodeEofError>
fn read_3bits(&mut self) -> Result<u3, CodeEofError>
Read three bits.
Sourcefn read_4bits(&mut self) -> Result<u4, CodeEofError>
fn read_4bits(&mut self) -> Result<u4, CodeEofError>
Read four bits.
Sourcefn read_5bits(&mut self) -> Result<u5, CodeEofError>
fn read_5bits(&mut self) -> Result<u5, CodeEofError>
Read five bits.
Sourcefn read_6bits(&mut self) -> Result<u6, CodeEofError>
fn read_6bits(&mut self) -> Result<u6, CodeEofError>
Read six bits.
Sourcefn read_7bits(&mut self) -> Result<u7, CodeEofError>
fn read_7bits(&mut self) -> Result<u7, CodeEofError>
Read seven bits.
Sourcefn read_byte(&mut self) -> Result<u8, CodeEofError>
fn read_byte(&mut self) -> Result<u8, CodeEofError>
Read byte.
Sourcefn read_word(&mut self) -> Result<u16, CodeEofError>
fn read_word(&mut self) -> Result<u16, CodeEofError>
Read word.
Sourcefn read_fixed<N, const LEN: usize>(
&mut self,
f: impl FnOnce([u8; LEN]) -> N,
) -> Result<N, CodeEofError>
fn read_fixed<N, const LEN: usize>( &mut self, f: impl FnOnce([u8; LEN]) -> N, ) -> Result<N, CodeEofError>
Read the fixed number of bytes and convert it into a result type.
§Returns
Resulting data type and a flag for CK
registry indicating whether it was possible to read
all the data.
Sourcefn read_bytes(
&mut self,
) -> Result<(Confined<Vec<u8>, amplify::::collection::confinement::SmallBlob::{constant#0}, amplify::::collection::confinement::SmallBlob::{constant#1}>, bool), CodeEofError>
fn read_bytes( &mut self, ) -> Result<(Confined<Vec<u8>, amplify::::collection::confinement::SmallBlob::{constant#0}, amplify::::collection::confinement::SmallBlob::{constant#1}>, bool), CodeEofError>
Read variable-length byte string.
§Returns
Resulting data type and a flag for CK
registry indicating whether it was possible to read
all the data.
Sourcefn read_ref(&mut self) -> Result<Id, CodeEofError>
fn read_ref(&mut self) -> Result<Id, CodeEofError>
Read external reference id.
Sourcefn check_aligned(&self)
fn check_aligned(&self)
Check if the current cursor position is aligned to the next byte.
§Panics
If the position is not aligned, panics.
Provided Methods§
Sourcefn read_bool(&mut self) -> Result<bool, CodeEofError>
fn read_bool(&mut self) -> Result<bool, CodeEofError>
Read single bit as a bool value.
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.