Struct polkavm::ProgramBlob

source ·
pub struct ProgramBlob<'a> { /* private fields */ }
Expand description

A partially deserialized PolkaVM program.

Implementations§

source§

impl<'a> ProgramBlob<'a>

source

pub fn parse( bytes: impl Into<CowBytes<'a>>, ) -> Result<ProgramBlob<'a>, ProgramParseError>

Parses the given bytes into a program blob.

source

pub fn as_bytes(&self) -> &[u8]

Returns the original bytes from which this program blob was created from.

source

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.

source

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.

source

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.

source

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.

source

pub fn stack_size(&self) -> u32

Returns the initial size of the stack.

source

pub fn code(&self) -> &[u8]

Returns the program code in its raw form.

source

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!

source

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!

source

pub fn imports( &self, ) -> impl Iterator<Item = Result<ProgramImport<'_>, ProgramParseError>> + Clone

Returns an iterator over program imports.

source

pub fn exports( &self, ) -> impl Iterator<Item = Result<ProgramExport<'_>, ProgramParseError>> + Clone

Returns an iterator over program exports.

source

pub fn instructions( &self, ) -> impl Iterator<Item = Result<Instruction, ProgramParseError>> + Clone

Returns an iterator over program instructions.

source

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.

source

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.

source

pub fn get_debug_string(&self, offset: u32) -> Result<&str, ProgramParseError>

Returns the debug string for the given relative offset.

source

pub fn get_debug_line_program_at( &self, nth_instruction: u32, ) -> Result<Option<LineProgram<'_>>, ProgramParseError>

Returns the line program for the given instruction.

source

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>

source§

fn clone(&self) -> ProgramBlob<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Default for ProgramBlob<'a>

source§

fn default() -> ProgramBlob<'a>

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.