unc_sdk/types/
vm_types.rs

1#[cfg(all(not(target_arch = "wasm32"), feature = "unit-testing"))]
2pub use unc_vm_runner::logic::types::{PromiseResult as VmPromiseResult, ReturnData};
3
4//* Types from unc_vm_logic
5/// Promise index that is computed only once.
6#[derive(Debug, Eq, PartialEq, PartialOrd, Ord, Hash, Copy, Clone)]
7pub struct PromiseIndex(pub(crate) u64);
8
9/// An index of Receipt to append an action
10#[deprecated(since = "2.1.0", note = "type not used within SDK, use u64 directly or another alias")]
11pub type ReceiptIndex = u64;
12#[deprecated(since = "2.1.0", note = "type not used within SDK, use u64 directly or another alias")]
13pub type IteratorIndex = u64;
14
15/// When there is a callback attached to one or more contract calls the execution results of these
16/// calls are available to the contract invoked through the callback.
17#[derive(Debug, PartialEq, Eq)]
18pub enum PromiseResult {
19    Successful(Vec<u8>),
20    Failed,
21}
22
23#[cfg(all(not(target_arch = "wasm32"), feature = "unit-testing"))]
24impl From<PromiseResult> for VmPromiseResult {
25    fn from(p: PromiseResult) -> Self {
26        match p {
27            PromiseResult::Successful(v) => Self::Successful(v),
28            PromiseResult::Failed => Self::Failed,
29        }
30    }
31}
32
33/// All error variants which can occur with promise results.
34#[non_exhaustive]
35#[derive(Debug, PartialEq, Eq)]
36pub enum PromiseError {
37    /// Promise result failed.
38    Failed,
39}