Struct Env

Source
#[repr(C)]
pub struct Env<'a> { /* private fields */ }
Expand description

Ephemeral execution environment.

In guest environment equivalent to just EnvState, while on Unix and Windows an executor context is also present

Implementations§

Source§

impl<'a> Env<'a>

Source

pub fn with_executor_context( state: EnvState, executor_context: &'a mut dyn ExecutorContext, ) -> Self

Instantiate environment with executor context

Source

pub fn get_mut_executor_context(&mut self) -> &mut dyn ExecutorContext

Instantiate environment with executor context

Source

pub fn shard_index(&self) -> ShardIndex

Shard index where execution is happening

Source

pub fn own_address(&self) -> Address

Own address of the contract

Source

pub fn context<'b>(self: &'b &'b mut Self) -> Address

Context of the execution

Source

pub fn caller<'b>(self: &'b &'b mut Self) -> Address

Caller of this contract

Source

pub fn call<Args>( &self, contract: Address, args: &mut Args, method_context: MethodContext, ) -> Result<(), ContractError>
where Args: ExternalArgs,

Call a method at specified address and with specified arguments.

This is a shortcut for Self::prepare_method_call() + Self::call_prepared().

Source

pub fn prepare_method_call<Args>( contract: Address, args: &mut Args, method_context: MethodContext, ) -> PreparedMethod<'_>
where Args: ExternalArgs,

Prepare a single method for calling at specified address and with specified arguments.

The result is to be used with Self::call_prepared() afterward.

Source

pub fn call_prepared( &self, method: PreparedMethod<'_>, ) -> Result<(), ContractError>

Call prepared method.

In most cases, this doesn’t need to be called directly. Extension traits provide a more convenient way to make method calls and are enough in most cases.

Trait Implementations§

Source§

impl<'a> Debug for Env<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Env<'a>

§

impl<'a> !RefUnwindSafe for Env<'a>

§

impl<'a> !Send for Env<'a>

§

impl<'a> !Sync for Env<'a>

§

impl<'a> Unpin for Env<'a>

§

impl<'a> !UnwindSafe for Env<'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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.