Trait BytecodeRead

Source
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§

Source

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.

Source

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.

Source

fn is_eof(&self) -> bool

Return whether end of the bytecode is reached.

Source

fn peek_byte(&self) -> Result<u8, CodeEofError>

Peek a single byte without moving cursor.

Source

fn read_1bit(&mut self) -> Result<u1, CodeEofError>

Read single bit.

Source

fn read_2bits(&mut self) -> Result<u2, CodeEofError>

Read two bits.

Source

fn read_3bits(&mut self) -> Result<u3, CodeEofError>

Read three bits.

Source

fn read_4bits(&mut self) -> Result<u4, CodeEofError>

Read four bits.

Source

fn read_5bits(&mut self) -> Result<u5, CodeEofError>

Read five bits.

Source

fn read_6bits(&mut self) -> Result<u6, CodeEofError>

Read six bits.

Source

fn read_7bits(&mut self) -> Result<u7, CodeEofError>

Read seven bits.

Source

fn read_byte(&mut self) -> Result<u8, CodeEofError>

Read byte.

Source

fn read_word(&mut self) -> Result<u16, CodeEofError>

Read word.

Source

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.

Source

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.

Source

fn read_ref(&mut self) -> Result<Id, CodeEofError>

Read external reference id.

Source

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§

Source

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.

Implementors§

Source§

impl<'a, C, D> BytecodeRead<LibId> for Marshaller<'a, C, D>
where C: AsRef<[u8]>, D: AsRef<[u8]>, Marshaller<'a, C, D>: 'a,