Struct fuel_vm::interpreter::Interpreter
source · [−]pub struct Interpreter<S> { /* private fields */ }
Expand description
VM interpreter.
The internal state of the VM isn’t expose because the intended usage is to either inspect the resulting receipts after a transaction execution, or the resulting mutated transaction.
These can be obtained with the help of a crate::transactor::Transactor
or a client implementation.
Implementations
sourceimpl<S> Interpreter<S>
impl<S> Interpreter<S>
sourcepub fn with_storage(storage: S) -> Self
pub fn with_storage(storage: S) -> Self
Create a new interpreter instance out of a storage implementation.
If the provided storage implements
crate::storage::InterpreterStorage
, the returned interpreter
will provide full functionality.
sourceimpl Interpreter<()>
impl Interpreter<()>
sourcepub fn without_storage() -> Self
pub fn without_storage() -> Self
Create a new interpreter without a storage backend.
It will have restricted capabilities.
sourceimpl Interpreter<MemoryStorage>
impl Interpreter<MemoryStorage>
sourcepub fn with_memory_storage() -> Self
pub fn with_memory_storage() -> Self
Create a new storage with a provided in-memory storage.
It will have full capabilities.
sourceimpl<S> Interpreter<S> where
S: InterpreterStorage,
impl<S> Interpreter<S> where
S: InterpreterStorage,
sourcepub fn execute(&mut self) -> Result<ExecuteState, InterpreterError>
pub fn execute(&mut self) -> Result<ExecuteState, InterpreterError>
Execute the current instruction pair located in $m[$pc]
.
sourcepub fn instruction(
&mut self,
instruction: Instruction
) -> Result<ExecuteState, InterpreterError>
pub fn instruction(
&mut self,
instruction: Instruction
) -> Result<ExecuteState, InterpreterError>
Execute a provided instruction
sourceimpl<S> Interpreter<S> where
S: InterpreterStorage,
impl<S> Interpreter<S> where
S: InterpreterStorage,
sourcepub fn transact_owned(
storage: S,
tx: Transaction
) -> Result<StateTransition, InterpreterError>
pub fn transact_owned(
storage: S,
tx: Transaction
) -> Result<StateTransition, InterpreterError>
Allocate internally a new instance of Interpreter
with the provided
storage, initialize it with the provided transaction and return the
result of th execution in form of StateTransition
sourcepub fn transact(
&mut self,
tx: Transaction
) -> Result<StateTransitionRef<'_>, InterpreterError>
pub fn transact(
&mut self,
tx: Transaction
) -> Result<StateTransitionRef<'_>, InterpreterError>
Initialize a pre-allocated instance of Interpreter
with the provided
transaction and execute it. The result will be bound to the lifetime
of the interpreter and will avoid unnecessary copy with the data
that can be referenced from the interpreter instance itself.
sourceimpl<S> Interpreter<S>
impl<S> Interpreter<S>
sourcepub fn memory(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn memory(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Returns the current state of the VM memory
sourcepub const fn transaction(&self) -> &TransactionⓘNotable traits for Transactionimpl Write for Transactionimpl Read for Transaction
pub const fn transaction(&self) -> &TransactionⓘNotable traits for Transactionimpl Write for Transactionimpl Read for Transaction
The current transaction
Trait Implementations
sourceimpl<S> AsMut<S> for Interpreter<S>
impl<S> AsMut<S> for Interpreter<S>
sourceimpl<S> AsRef<Interpreter<S>> for Transactor<'_, S>
impl<S> AsRef<Interpreter<S>> for Transactor<'_, S>
sourcefn as_ref(&self) -> &Interpreter<S>
fn as_ref(&self) -> &Interpreter<S>
Converts this type into a shared reference of the (usually inferred) input type.
sourceimpl<S> AsRef<S> for Interpreter<S>
impl<S> AsRef<S> for Interpreter<S>
sourceimpl<S: Clone> Clone for Interpreter<S>
impl<S: Clone> Clone for Interpreter<S>
sourcefn clone(&self) -> Interpreter<S>
fn clone(&self) -> Interpreter<S>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<S: Debug> Debug for Interpreter<S>
impl<S: Debug> Debug for Interpreter<S>
sourceimpl<S> Default for Interpreter<S> where
S: Default,
impl<S> Default for Interpreter<S> where
S: Default,
sourceimpl<S> From<Interpreter<S>> for Transaction
impl<S> From<Interpreter<S>> for Transaction
sourcefn from(vm: Interpreter<S>) -> Self
fn from(vm: Interpreter<S>) -> Self
Converts to this type from the input type.
sourceimpl<S> From<Interpreter<S>> for Transactor<'_, S>
impl<S> From<Interpreter<S>> for Transactor<'_, S>
sourcefn from(interpreter: Interpreter<S>) -> Self
fn from(interpreter: Interpreter<S>) -> Self
Converts to this type from the input type.
sourceimpl<S> From<Transactor<'_, S>> for Interpreter<S>
impl<S> From<Transactor<'_, S>> for Interpreter<S>
sourcefn from(transactor: Transactor<'_, S>) -> Self
fn from(transactor: Transactor<'_, S>) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl<S> RefUnwindSafe for Interpreter<S> where
S: RefUnwindSafe,
impl<S> Send for Interpreter<S> where
S: Send,
impl<S> Sync for Interpreter<S> where
S: Sync,
impl<S> Unpin for Interpreter<S> where
S: Unpin,
impl<S> UnwindSafe for Interpreter<S> where
S: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToHex for T where
T: AsRef<[u8]>,
impl<T> ToHex for T where
T: AsRef<[u8]>,
sourcefn encode_hex<U>(&self) -> U where
U: FromIterator<char>,
fn encode_hex<U>(&self) -> U where
U: FromIterator<char>,
Encode the hex strict representing self
into the result. Lower case
letters are used (e.g. f9b4ca
) Read more
sourcefn encode_hex_upper<U>(&self) -> U where
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> U where
U: FromIterator<char>,
Encode the hex strict representing self
into the result. Upper case
letters are used (e.g. F9B4CA
) Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more