pub enum OptionalValue<T> {
Some(T),
None,
}
Expand description
A smart contract argument or result that can be missing.
If arguments stop before this argument, None will be returned. As an endpoint result, the contract decides if it produces it or not.
As a principle, optional arguments or results should come last, otherwise there is ambiguity as to how to interpret what comes after.
Variants§
Implementations§
Trait Implementations§
Source§impl<T> Clone for OptionalValue<T>where
T: Clone,
impl<T> Clone for OptionalValue<T>where
T: Clone,
Source§fn clone(&self) -> OptionalValue<T>
fn clone(&self) -> OptionalValue<T>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<T> Debug for OptionalValue<T>where
T: Debug,
impl<T> Debug for OptionalValue<T>where
T: Debug,
Source§impl<T> From<Option<T>> for OptionalValue<T>
impl<T> From<Option<T>> for OptionalValue<T>
Source§fn from(v: Option<T>) -> OptionalValue<T>
fn from(v: Option<T>) -> OptionalValue<T>
Converts to this type from the input type.
Source§impl<T> TopDecodeMulti for OptionalValue<T>where
T: TopDecodeMulti,
impl<T> TopDecodeMulti for OptionalValue<T>where
T: TopDecodeMulti,
fn multi_decode_or_handle_err<I, H>(
input: &mut I,
h: H,
) -> Result<OptionalValue<T>, <H as DecodeErrorHandler>::HandledErr>where
I: TopDecodeMultiInput,
H: DecodeErrorHandler,
Source§const IS_SINGLE_VALUE: bool = false
const IS_SINGLE_VALUE: bool = false
Used to optimize single value loading of endpoint arguments.
fn multi_decode<I>(input: &mut I) -> Result<Self, DecodeError>where
I: TopDecodeMultiInput,
Source§impl<T> TopEncodeMulti for OptionalValue<T>where
T: TopEncodeMulti,
impl<T> TopEncodeMulti for OptionalValue<T>where
T: TopEncodeMulti,
Source§fn multi_encode_or_handle_err<O, H>(
&self,
output: &mut O,
h: H,
) -> Result<(), <H as EncodeErrorHandler>::HandledErr>where
O: TopEncodeMultiOutput,
H: EncodeErrorHandler,
fn multi_encode_or_handle_err<O, H>(
&self,
output: &mut O,
h: H,
) -> Result<(), <H as EncodeErrorHandler>::HandledErr>where
O: TopEncodeMultiOutput,
H: EncodeErrorHandler,
Version of
top_encode
that can handle errors as soon as they occur.
For instance in can exit immediately and make sure that if it returns, it is a success.
By not deferring error handling, this can lead to somewhat smaller bytecode.Source§fn multi_encode<O>(&self, output: &mut O) -> Result<(), EncodeError>where
O: TopEncodeMultiOutput,
fn multi_encode<O>(&self, output: &mut O) -> Result<(), EncodeError>where
O: TopEncodeMultiOutput,
Attempt to serialize the value to ouput.
Source§impl<T> TypeAbi for OptionalValue<T>where
T: TypeAbi,
impl<T> TypeAbi for OptionalValue<T>where
T: TypeAbi,
type Unmanaged = OptionalValue<<T as TypeAbi>::Unmanaged>
fn type_name() -> String
fn type_name_rust() -> String
Source§fn provide_type_descriptions<TDC>(accumulator: &mut TDC)where
TDC: TypeDescriptionContainer,
fn provide_type_descriptions<TDC>(accumulator: &mut TDC)where
TDC: TypeDescriptionContainer,
A type can provide more than its own name.
For instance, a struct can also provide the descriptions of the type of its fields.
TypeAbi doesn’t care for the exact accumulator type,
which is abstracted by the TypeDescriptionContainer trait.
fn type_names() -> TypeNames
impl<T, U> TypeAbiFrom<OptionalValue<U>> for OptionalValue<T>where
T: TypeAbiFrom<U>,
Auto Trait Implementations§
impl<T> Freeze for OptionalValue<T>where
T: Freeze,
impl<T> RefUnwindSafe for OptionalValue<T>where
T: RefUnwindSafe,
impl<T> Send for OptionalValue<T>where
T: Send,
impl<T> Sync for OptionalValue<T>where
T: Sync,
impl<T> Unpin for OptionalValue<T>where
T: Unpin,
impl<T> UnwindSafe for OptionalValue<T>where
T: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> InterpretableFrom<&T> for Twhere
T: Clone,
impl<T> InterpretableFrom<&T> for Twhere
T: Clone,
fn interpret_from(from: &T, _context: &InterpreterContext) -> T
Source§impl<T> InterpretableFrom<T> for T
impl<T> InterpretableFrom<T> for T
fn interpret_from(from: T, _context: &InterpreterContext) -> T
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