Enum dharitri_codec::multi_types::OptionalValue
source · 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§
source§impl<T> OptionalValue<T>
impl<T> OptionalValue<T>
pub fn into_option(self) -> Option<T>
Trait Implementations§
source§impl<T: Clone> Clone for OptionalValue<T>
impl<T: Clone> Clone for OptionalValue<T>
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> From<Option<T>> for OptionalValue<T>
impl<T> From<Option<T>> for OptionalValue<T>
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<Self, H::HandledErr>where
I: TopDecodeMultiInput,
H: DecodeErrorHandler,
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,
§type DecodeAs = OptionalValue<T>
type DecodeAs = OptionalValue<T>
Indicates how the encoding result should be interpreted when deserializing back.
Self for most types. Read moresource§fn multi_encode_or_handle_err<O, H>(
&self,
output: &mut O,
h: H
) -> Result<(), H::HandledErr>where
O: TopEncodeMultiOutput,
H: EncodeErrorHandler,
fn multi_encode_or_handle_err<O, H>(
&self,
output: &mut O,
h: H
) -> Result<(), H::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.
Auto Trait Implementations§
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