Enum unc_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::ext("bob_unc".parse().unwrap()).a().into()
};Variants§
Trait Implementations§
source§impl<T> BorshSchema for PromiseOrValue<T>where
T: BorshSchema,
impl<T> BorshSchema for PromiseOrValue<T>where
T: BorshSchema,
source§fn add_definitions_recursively(
definitions: &mut BTreeMap<Declaration, Definition>
)
fn add_definitions_recursively( definitions: &mut BTreeMap<Declaration, Definition> )
Recursively, using DFS, add type definitions required for this type.
Type definition partially explains how to serialize/deserialize a type.
source§fn declaration() -> Declaration
fn declaration() -> Declaration
Get the name of the type without brackets.
source§impl<T: BorshSerialize> BorshSerialize for PromiseOrValue<T>
impl<T: BorshSerialize> BorshSerialize for PromiseOrValue<T>
source§impl<T> From<Promise> for PromiseOrValue<T>
impl<T> From<Promise> for PromiseOrValue<T>
source§impl<T: JsonSchema> JsonSchema for PromiseOrValue<T>
impl<T: JsonSchema> JsonSchema for PromiseOrValue<T>
source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
source§fn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreAuto Trait Implementations§
impl<T> !Freeze for PromiseOrValue<T>
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§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more