pub struct NativeResult {
    pub cost: InternalGas,
    pub result: Result<SmallVec<[Value; 1]>, u64>,
}
Expand description

Result of a native function execution requires charges for execution cost.

An execution that causes an invariant violation would not return a NativeResult but return a PartialVMError error directly. All native functions must return a PartialVMResult<NativeResult> where an Err is returned when an error condition is met that should not charge for the execution. A common example is a VM invariant violation which should have been forbidden by the verifier. Errors (typically user errors and aborts) that are logically part of the function execution must be expressed in a NativeResult with a cost and a VMStatus.

Fields

cost: InternalGas

Result of execution. This is either the return values or the error to report.

result: Result<SmallVec<[Value; 1]>, u64>

Implementations

Return values of a successful execution.

Failed execution. The failure is a runtime failure in the function and not an invariant failure of the VM which would raise a PartialVMError error directly. The only thing the funciton can specify is its abort code, as if it had invoked the Abort bytecode instruction

Convert a PartialVMResult<()> into a PartialVMResult

Convert a PartialVMResult into a PartialVMResult

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.