Skip to main content

ExecutorContext

Trait ExecutorContext 

Source
pub unsafe trait ExecutorContext: Debug {
    // Required method
    fn call(
        &self,
        previous_env_state: &EnvState,
        prepared_method: &PreparedMethod<'_>,
    ) -> Result<(), ContractError>;
}
Expand description

Executor context that can be used to interact with executor.

§Safety

Self::call() gets pointers to arguments of a method call in PreparedMethod, and callers like methods generated by #[contract] rely on implementations to:

  • write only initialized bytes, including when returning an error
  • write nothing but the contents of outputs within their capacity, the sizes of outputs in ExternalArgs and the return value (if there is one)
  • not read the return value, or bytes of outputs beyond their size, before writing them, since they may be uninitialized
  • keep the size of each output in ExternalArgs valid for its type and within its capacity, with that many bytes of the output initialized, since extension methods set it on the output they were given, as OutputArg::set_output_size() requires
  • initialize the return value (if there is one) before returning Ok(())
  • not access memory behind any of these pointers after Self::call() returns

Contents don’t need to be valid values of their types: extension methods parse return values, and contents of outputs are only accessed after being parsed, unless every bit pattern is a valid value (see OutputArg).

Required Methods§

Source

fn call( &self, previous_env_state: &EnvState, prepared_method: &PreparedMethod<'_>, ) -> Result<(), ContractError>

Call prepared method

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§