Struct move_vm_types::natives::function::NativeResult
source · [−]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: InternalGasResult of execution. This is either the return values or the error to report.
result: Result<SmallVec<[Value; 1]>, u64>Implementations
sourceimpl NativeResult
impl NativeResult
sourcepub fn ok(cost: InternalGas, values: SmallVec<[Value; 1]>) -> Self
pub fn ok(cost: InternalGas, values: SmallVec<[Value; 1]>) -> Self
Return values of a successful execution.
sourcepub fn err(cost: InternalGas, abort_code: u64) -> Self
pub fn err(cost: InternalGas, abort_code: u64) -> Self
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
sourcepub fn map_partial_vm_result_empty(
cost: InternalGas,
res: PartialVMResult<()>
) -> PartialVMResult<Self>
pub fn map_partial_vm_result_empty(
cost: InternalGas,
res: PartialVMResult<()>
) -> PartialVMResult<Self>
Convert a PartialVMResult<()> into a PartialVMResult
sourcepub fn map_partial_vm_result_one(
cost: InternalGas,
res: PartialVMResult<Value>
) -> PartialVMResult<Self>
pub fn map_partial_vm_result_one(
cost: InternalGas,
res: PartialVMResult<Value>
) -> PartialVMResult<Self>
Convert a PartialVMResult
Auto Trait Implementations
impl !RefUnwindSafe for NativeResult
impl !Send for NativeResult
impl !Sync for NativeResult
impl Unpin for NativeResult
impl !UnwindSafe for NativeResult
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