Trait BackendTermination

Source
pub trait BackendTermination<Ext: BackendExternalities>: Sized {
    // Required method
    fn into_parts(self) -> (Ext, UndefinedTerminationReason);

    // Provided method
    fn terminate<T: Debug, WasmCallErr: Debug>(
        self,
        res: Result<T, WasmCallErr>,
        gas: u64,
    ) -> (Ext, TerminationReason) { ... }
}
Expand description

A trait for termination of the gear sys-calls execution backend.

Backend termination aims to return to the caller gear wasm program execution outcome, which is the state of externalities, memory and termination reason.

Required Methods§

Source

fn into_parts(self) -> (Ext, UndefinedTerminationReason)

Transforms Self into tuple of externalities, memory and termination reason returned after the execution.

Provided Methods§

Source

fn terminate<T: Debug, WasmCallErr: Debug>( self, res: Result<T, WasmCallErr>, gas: u64, ) -> (Ext, TerminationReason)

Terminates backend work after execution.

The function handles res, which is the result of gear wasm program entry point invocation, and the termination reason.

If the res is Ok, then execution considered successful and the termination reason will have the corresponding value.

If the res is Err, then execution is considered to end with an error and the actual termination reason, which stores more precise information about the error, is returned.

There’s a case, when res is Err, but termination reason has a value for the successful ending of the execution. This is the case of calling unreachable panic in the program.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Ext: BackendExternalities, Mem> BackendTermination<Ext> for State<Ext, Mem>