pub enum PromiseOrValue<T> {
    Promise(Promise),
    Value(T),
}
Expand description

When the method can return either a promise or a value, it can be called with PromiseOrValue::Promise or PromiseOrValue::Value to specify which one should be returned.

Example

#[ext_contract]
pub trait ContractA {
    fn a(&mut self);
}

let value = Some(true);
let val: PromiseOrValue<bool> = if let Some(value) = value {
    PromiseOrValue::Value(value)
} else {
    contract_a::a("bob_near".parse().unwrap(), 0, Gas(1_000)).into()
};

Variants

Promise(Promise)

Value(T)

Trait Implementations

Recursively, using DFS, add type definitions required for this type. For primitive types this is an empty map. Type definition explains how to serialize/deserialize a type. Read more

Get the name of the type without brackets.

Helper method to add a single type definition to the map.

Serialize this instance into a vector of bytes.

Converts to this type from the input type.

Serialize this value into the given Serde serializer. Read more

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.

Should always be Self

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.