Struct polkavm::ProgramBlob
source · pub struct ProgramBlob<'a> { /* private fields */ }
Expand description
A partially deserialized PolkaVM program.
Implementations§
source§impl<'a> ProgramBlob<'a>
impl<'a> ProgramBlob<'a>
sourcepub fn parse(
bytes: impl Into<CowBytes<'a>>,
) -> Result<ProgramBlob<'a>, ProgramParseError>
pub fn parse( bytes: impl Into<CowBytes<'a>>, ) -> Result<ProgramBlob<'a>, ProgramParseError>
Parses the given bytes into a program blob.
sourcepub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_bytes(&self) -> &[u8] ⓘ
Returns the original bytes from which this program blob was created from.
sourcepub fn ro_data(&self) -> &[u8] ⓘ
pub fn ro_data(&self) -> &[u8] ⓘ
Returns the contents of the read-only data section.
This only covers the initial non-zero portion of the section; use ro_data_size
to get the full size.
sourcepub fn ro_data_size(&self) -> u32
pub fn ro_data_size(&self) -> u32
Returns the size of the read-only data section.
This can be larger than the length of ro_data
, in which case the rest of the space is assumed to be filled with zeros.
sourcepub fn rw_data(&self) -> &[u8] ⓘ
pub fn rw_data(&self) -> &[u8] ⓘ
Returns the contents of the read-write data section.
This only covers the initial non-zero portion of the section; use rw_data_size
to get the full size.
sourcepub fn rw_data_size(&self) -> u32
pub fn rw_data_size(&self) -> u32
Returns the size of the read-write data section.
This can be larger than the length of rw_data
, in which case the rest of the space is assumed to be filled with zeros.
sourcepub fn stack_size(&self) -> u32
pub fn stack_size(&self) -> u32
Returns the initial size of the stack.
sourcepub fn instruction_count(&self) -> u32
pub fn instruction_count(&self) -> u32
Returns the number of instructions the code section should contain.
NOTE: It is safe to preallocate memory based on this value as we make sure that it is no larger than the the physical size of the code section, however we do not verify that it is actually true, so it should not be blindly trusted!
sourcepub fn basic_block_count(&self) -> u32
pub fn basic_block_count(&self) -> u32
Returns the number of basic blocks the code section should contain.
NOTE: It is safe to preallocate memory based on this value as we make sure that it is no larger than the the physical size of the code section, however we do not verify that it is actually true, so it should not be blindly trusted!
sourcepub fn imports(
&self,
) -> impl Iterator<Item = Result<ProgramImport<'_>, ProgramParseError>> + Clone
pub fn imports( &self, ) -> impl Iterator<Item = Result<ProgramImport<'_>, ProgramParseError>> + Clone
Returns an iterator over program imports.
sourcepub fn exports(
&self,
) -> impl Iterator<Item = Result<ProgramExport<'_>, ProgramParseError>> + Clone
pub fn exports( &self, ) -> impl Iterator<Item = Result<ProgramExport<'_>, ProgramParseError>> + Clone
Returns an iterator over program exports.
sourcepub fn instructions(
&self,
) -> impl Iterator<Item = Result<Instruction, ProgramParseError>> + Clone
pub fn instructions( &self, ) -> impl Iterator<Item = Result<Instruction, ProgramParseError>> + Clone
Returns an iterator over program instructions.
sourcepub fn jump_table_upper_bound(&self) -> usize
pub fn jump_table_upper_bound(&self) -> usize
The upper bound of how many entries there might be in this program’s jump table, excluding the very first implicit entry.
sourcepub fn jump_table(
&self,
) -> impl Iterator<Item = Result<u32, ProgramParseError>> + Clone
pub fn jump_table( &self, ) -> impl Iterator<Item = Result<u32, ProgramParseError>> + Clone
Returns an iterator over the jump table entries, excluding the very first implicit entry.
sourcepub fn get_debug_string(&self, offset: u32) -> Result<&str, ProgramParseError>
pub fn get_debug_string(&self, offset: u32) -> Result<&str, ProgramParseError>
Returns the debug string for the given relative offset.
sourcepub fn get_debug_line_program_at(
&self,
nth_instruction: u32,
) -> Result<Option<LineProgram<'_>>, ProgramParseError>
pub fn get_debug_line_program_at( &self, nth_instruction: u32, ) -> Result<Option<LineProgram<'_>>, ProgramParseError>
Returns the line program for the given instruction.
sourcepub fn into_owned(self) -> ProgramBlob<'static>
pub fn into_owned(self) -> ProgramBlob<'static>
Returns an owned program blob, possibly cloning it if it was deserialized in a zero-copy fashion.
Trait Implementations§
source§impl<'a> Clone for ProgramBlob<'a>
impl<'a> Clone for ProgramBlob<'a>
source§fn clone(&self) -> ProgramBlob<'a>
fn clone(&self) -> ProgramBlob<'a>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<'a> Default for ProgramBlob<'a>
impl<'a> Default for ProgramBlob<'a>
source§fn default() -> ProgramBlob<'a>
fn default() -> ProgramBlob<'a>
Auto Trait Implementations§
impl<'a> Freeze for ProgramBlob<'a>
impl<'a> RefUnwindSafe for ProgramBlob<'a>
impl<'a> Send for ProgramBlob<'a>
impl<'a> Sync for ProgramBlob<'a>
impl<'a> Unpin for ProgramBlob<'a>
impl<'a> UnwindSafe for ProgramBlob<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)