Enum near_sdk::PromiseOrValue
source · [−]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
sourceimpl<T> BorshSchema for PromiseOrValue<T> where
T: BorshSchema,
impl<T> BorshSchema for PromiseOrValue<T> where
T: BorshSchema,
sourcefn add_definitions_recursively(
definitions: &mut HashMap<Declaration, Definition>
)
fn add_definitions_recursively(
definitions: &mut HashMap<Declaration, Definition>
)
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
sourcefn declaration() -> Declaration
fn declaration() -> Declaration
Get the name of the type without brackets.
sourcefn add_definition(
declaration: String,
definition: Definition,
definitions: &mut HashMap<String, Definition, RandomState>
)
fn add_definition(
declaration: String,
definition: Definition,
definitions: &mut HashMap<String, Definition, RandomState>
)
Helper method to add a single type definition to the map.
fn schema_container() -> BorshSchemaContainer
sourceimpl<T: BorshSerialize> BorshSerialize for PromiseOrValue<T>
impl<T: BorshSerialize> BorshSerialize for PromiseOrValue<T>
sourceimpl<T> From<Promise> for PromiseOrValue<T>
impl<T> From<Promise> for PromiseOrValue<T>
Auto Trait Implementations
impl<T> !RefUnwindSafe for PromiseOrValue<T>
impl<T> !Send for PromiseOrValue<T>
impl<T> !Sync for PromiseOrValue<T>
impl<T> Unpin for PromiseOrValue<T> where
T: Unpin,
impl<T> !UnwindSafe for PromiseOrValue<T>
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