Trait BytecodeWrite

Source
pub trait BytecodeWrite<Id>
where Id: SiteId,
{ type Error: Debug;
Show 14 methods // Required methods fn write_1bit(&mut self, data: u1) -> Result<(), Self::Error>; fn write_2bits(&mut self, data: u2) -> Result<(), Self::Error>; fn write_3bits(&mut self, data: u3) -> Result<(), Self::Error>; fn write_4bits(&mut self, data: u4) -> Result<(), Self::Error>; fn write_5bits(&mut self, data: u5) -> Result<(), Self::Error>; fn write_6bits(&mut self, data: u6) -> Result<(), Self::Error>; fn write_7bits(&mut self, data: u7) -> Result<(), Self::Error>; fn write_byte(&mut self, data: u8) -> Result<(), Self::Error>; fn write_word(&mut self, data: u16) -> Result<(), Self::Error>; fn write_fixed<const LEN: usize>( &mut self, data: [u8; LEN], ) -> Result<(), Self::Error>; fn write_bytes(&mut self, data: &[u8]) -> Result<(), Self::Error>; fn write_ref(&mut self, id: Id) -> Result<(), Self::Error>; fn check_aligned(&self); // Provided method fn write_bool(&mut self, data: bool) -> Result<(), Self::Error> { ... }
}
Expand description

Writer converting instructions into a bytecode.

Required Associated Types§

Source

type Error: Debug

Error type returned during writing procedures.

Required Methods§

Source

fn write_1bit(&mut self, data: u1) -> Result<(), Self::Error>

Write a single bit.

Source

fn write_2bits(&mut self, data: u2) -> Result<(), Self::Error>

Write two bits.

Source

fn write_3bits(&mut self, data: u3) -> Result<(), Self::Error>

Write three bits.

Source

fn write_4bits(&mut self, data: u4) -> Result<(), Self::Error>

Write four bits.

Source

fn write_5bits(&mut self, data: u5) -> Result<(), Self::Error>

Write five bits.

Source

fn write_6bits(&mut self, data: u6) -> Result<(), Self::Error>

Write six bits.

Source

fn write_7bits(&mut self, data: u7) -> Result<(), Self::Error>

Write seven bits.

Source

fn write_byte(&mut self, data: u8) -> Result<(), Self::Error>

Write byte.

Source

fn write_word(&mut self, data: u16) -> Result<(), Self::Error>

Write word.

Source

fn write_fixed<const LEN: usize>( &mut self, data: [u8; LEN], ) -> Result<(), Self::Error>

Write data representable as a fixed-length byte array.

Source

fn write_bytes(&mut self, data: &[u8]) -> Result<(), Self::Error>

Write variable-length byte string.

Source

fn write_ref(&mut self, id: Id) -> Result<(), Self::Error>

Write 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 write_bool(&mut self, data: bool) -> Result<(), Self::Error>

Write a single bit from 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> BytecodeWrite<LibId> for Marshaller<'a, C, D>
where C: AsRef<[u8]> + AsMut<[u8]> + Extend<u8>, D: AsRef<[u8]> + AsMut<[u8]> + Extend<u8>, Marshaller<'a, C, D>: 'a,