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::ext("bob_near".parse().unwrap()).a().into()
};
Variants§
Trait Implementations§
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>
Auto 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
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more