pub struct EgldOrEsdtTokenIdentifier<M: ManagedTypeApi> { /* private fields */ }
Expand description
Specialized type for handling either EGLD or ESDT token identifiers.
Equivalent to a structure of the form
enum EgldOrEsdtTokenIdentifier<M: ManagedTypeApi> {
Egld,
Esdt(TokenIdentifier<M>),
}
It is, however more optimized than that. Its implementation is based on ManagedOption
.
EGLD is indicated by a special, invalid token identifier handle. This way we can fit it inside a single i32 in memory.
Implementations§
Source§impl<M: ManagedTypeApi> EgldOrEsdtTokenIdentifier<M>
impl<M: ManagedTypeApi> EgldOrEsdtTokenIdentifier<M>
Sourcepub const EGLD_REPRESENTATION: &'static [u8; 4] = b"EGLD"
pub const EGLD_REPRESENTATION: &'static [u8; 4] = b"EGLD"
This special representation is interpreted as the EGLD token.
Sourcepub fn esdt<TI>(token_identifier: TI) -> Selfwhere
TokenIdentifier<M>: From<TI>,
pub fn esdt<TI>(token_identifier: TI) -> Selfwhere
TokenIdentifier<M>: From<TI>,
ESDT instance, containing an ESDT token identifier.
pub fn parse(data: ManagedBuffer<M>) -> Self
pub fn is_egld(&self) -> bool
pub fn is_esdt(&self) -> bool
Sourcepub fn into_name(self) -> ManagedBuffer<M>
pub fn into_name(self) -> ManagedBuffer<M>
Returns “EGLD” or the token identifier.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Checks the ESDT token identifier for validity. EGLD is considered valid, no checks needed.
Will fail if it encodes an invalid ESDT token identifier.
pub fn into_managed_buffer(self) -> ManagedBuffer<M>
pub fn as_managed_buffer(&self) -> &ManagedBuffer<M>
pub fn to_boxed_bytes(&self) -> BoxedBytes
pub fn map_or_else<Context, D, F, R>( self, context: Context, for_egld: D, for_esdt: F, ) -> R
pub fn map_ref_or_else<Context, D, F, R>( &self, context: Context, for_egld: D, for_esdt: F, ) -> R
pub fn unwrap_esdt(self) -> TokenIdentifier<M>
Sourcepub fn as_esdt_option(&self) -> Option<ManagedRef<'_, M, TokenIdentifier<M>>>
pub fn as_esdt_option(&self) -> Option<ManagedRef<'_, M, TokenIdentifier<M>>>
Representation of the object as an Option
.
Because it does not consume self
only a reference to the ESDT token identifier can be returned.
Sourcepub fn into_esdt_option(self) -> Option<TokenIdentifier<M>>
pub fn into_esdt_option(self) -> Option<TokenIdentifier<M>>
Converts self
into an Option
. Consumes self
in the process.
Trait Implementations§
Source§impl<M: Clone + ManagedTypeApi> Clone for EgldOrEsdtTokenIdentifier<M>
impl<M: Clone + ManagedTypeApi> Clone for EgldOrEsdtTokenIdentifier<M>
Source§fn clone(&self) -> EgldOrEsdtTokenIdentifier<M>
fn clone(&self) -> EgldOrEsdtTokenIdentifier<M>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<M> Debug for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> Debug for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
Source§impl<M: ManagedTypeApi> From<&[u8]> for EgldOrEsdtTokenIdentifier<M>
impl<M: ManagedTypeApi> From<&[u8]> for EgldOrEsdtTokenIdentifier<M>
Source§impl<M: ManagedTypeApi> From<ManagedBuffer<M>> for EgldOrEsdtTokenIdentifier<M>
impl<M: ManagedTypeApi> From<ManagedBuffer<M>> for EgldOrEsdtTokenIdentifier<M>
Source§fn from(buffer: ManagedBuffer<M>) -> Self
fn from(buffer: ManagedBuffer<M>) -> Self
Source§impl<M: ManagedTypeApi> ManagedType<M> for EgldOrEsdtTokenIdentifier<M>
impl<M: ManagedTypeApi> ManagedType<M> for EgldOrEsdtTokenIdentifier<M>
type OwnHandle = <M as HandleTypeInfo>::ManagedBufferHandle
fn get_handle(&self) -> M::ManagedBufferHandle
Source§unsafe fn forget_into_handle(self) -> Self::OwnHandle
unsafe fn forget_into_handle(self) -> Self::OwnHandle
Source§fn transmute_from_handle_ref(handle_ref: &M::ManagedBufferHandle) -> &Self
fn transmute_from_handle_ref(handle_ref: &M::ManagedBufferHandle) -> &Self
fn transmute_from_handle_ref_mut( handle_ref: &mut M::ManagedBufferHandle, ) -> &mut Self
fn get_raw_handle(&self) -> RawHandle
fn as_ref(&self) -> ManagedRef<'_, M, Self>
Source§impl<M: ManagedTypeApi> ManagedVecItem for EgldOrEsdtTokenIdentifier<M>
impl<M: ManagedTypeApi> ManagedVecItem for EgldOrEsdtTokenIdentifier<M>
Source§const SKIPS_RESERIALIZATION: bool = false
const SKIPS_RESERIALIZATION: bool = false
u32
).Source§type PAYLOAD = ManagedVecItemPayloadBuffer<4>
type PAYLOAD = ManagedVecItemPayloadBuffer<4>
Source§type Ref<'a> = ManagedRef<'a, M, EgldOrEsdtTokenIdentifier<M>>
type Ref<'a> = ManagedRef<'a, M, EgldOrEsdtTokenIdentifier<M>>
Source§fn read_from_payload(payload: &Self::PAYLOAD) -> Self
fn read_from_payload(payload: &Self::PAYLOAD) -> Self
Source§unsafe fn borrow_from_payload<'a>(payload: &Self::PAYLOAD) -> Self::Ref<'a>
unsafe fn borrow_from_payload<'a>(payload: &Self::PAYLOAD) -> Self::Ref<'a>
Source§fn save_to_payload(self, payload: &mut Self::PAYLOAD)
fn save_to_payload(self, payload: &mut Self::PAYLOAD)
fn payload_size() -> usize
Source§impl<M: ManagedTypeApi> NestedDecode for EgldOrEsdtTokenIdentifier<M>
impl<M: ManagedTypeApi> NestedDecode for EgldOrEsdtTokenIdentifier<M>
Source§fn dep_decode_or_handle_err<I, H>(
input: &mut I,
h: H,
) -> Result<Self, H::HandledErr>where
I: NestedDecodeInput,
H: DecodeErrorHandler,
fn dep_decode_or_handle_err<I, H>(
input: &mut I,
h: H,
) -> Result<Self, H::HandledErr>where
I: NestedDecodeInput,
H: DecodeErrorHandler,
dep_decode
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 dep_decode<I>(input: &mut I) -> Result<Self, DecodeError>where
I: NestedDecodeInput,
fn dep_decode<I>(input: &mut I) -> Result<Self, DecodeError>where
I: NestedDecodeInput,
Source§impl<M: ManagedTypeApi> NestedEncode for EgldOrEsdtTokenIdentifier<M>
impl<M: ManagedTypeApi> NestedEncode for EgldOrEsdtTokenIdentifier<M>
Source§fn dep_encode_or_handle_err<O, H>(
&self,
dest: &mut O,
h: H,
) -> Result<(), H::HandledErr>where
O: NestedEncodeOutput,
H: EncodeErrorHandler,
fn dep_encode_or_handle_err<O, H>(
&self,
dest: &mut O,
h: H,
) -> Result<(), H::HandledErr>where
O: NestedEncodeOutput,
H: EncodeErrorHandler,
dep_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 dep_encode<O>(&self, dest: &mut O) -> Result<(), EncodeError>where
O: NestedEncodeOutput,
fn dep_encode<O>(&self, dest: &mut O) -> Result<(), EncodeError>where
O: NestedEncodeOutput,
Source§impl<M: ManagedTypeApi> PartialEq<EgldOrEsdtTokenIdentifier<M>> for TokenIdentifier<M>
impl<M: ManagedTypeApi> PartialEq<EgldOrEsdtTokenIdentifier<M>> for TokenIdentifier<M>
Source§fn eq(&self, other: &EgldOrEsdtTokenIdentifier<M>) -> bool
fn eq(&self, other: &EgldOrEsdtTokenIdentifier<M>) -> bool
self
and other
values to be equal, and is used by ==
.Source§impl<M: ManagedTypeApi> PartialEq<TokenIdentifier<M>> for EgldOrEsdtTokenIdentifier<M>
impl<M: ManagedTypeApi> PartialEq<TokenIdentifier<M>> for EgldOrEsdtTokenIdentifier<M>
Source§impl<M: ManagedTypeApi> PartialEq for EgldOrEsdtTokenIdentifier<M>
impl<M: ManagedTypeApi> PartialEq for EgldOrEsdtTokenIdentifier<M>
Source§impl<M: ManagedTypeApi> SCDisplay for EgldOrEsdtTokenIdentifier<M>
impl<M: ManagedTypeApi> SCDisplay for EgldOrEsdtTokenIdentifier<M>
fn fmt<F: FormatByteReceiver>(&self, f: &mut F)
Source§impl<M: ManagedTypeApi> SCLowerHex for EgldOrEsdtTokenIdentifier<M>
impl<M: ManagedTypeApi> SCLowerHex for EgldOrEsdtTokenIdentifier<M>
fn fmt<F: FormatByteReceiver>(&self, f: &mut F)
Source§impl<M: ManagedTypeApi> TopDecode for EgldOrEsdtTokenIdentifier<M>
impl<M: ManagedTypeApi> TopDecode for EgldOrEsdtTokenIdentifier<M>
Source§fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>where
I: TopDecodeInput,
H: DecodeErrorHandler,
fn top_decode_or_handle_err<I, H>(input: I, h: H) -> Result<Self, H::HandledErr>where
I: TopDecodeInput,
H: DecodeErrorHandler,
top_decode
that can handle errors as soon as they occur.
For instance it 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 top_decode<I>(input: I) -> Result<Self, DecodeError>where
I: TopDecodeInput,
fn top_decode<I>(input: I) -> Result<Self, DecodeError>where
I: TopDecodeInput,
Source§impl<M: ManagedTypeApi> TopEncode for EgldOrEsdtTokenIdentifier<M>
impl<M: ManagedTypeApi> TopEncode for EgldOrEsdtTokenIdentifier<M>
Source§fn top_encode_or_handle_err<O, H>(
&self,
output: O,
h: H,
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
h: H,
) -> Result<(), H::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
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 top_encode<O>(&self, output: O) -> Result<(), EncodeError>where
O: TopEncodeOutput,
fn top_encode<O>(&self, output: O) -> Result<(), EncodeError>where
O: TopEncodeOutput,
Source§impl<M: ManagedTypeApi> TypeAbi for EgldOrEsdtTokenIdentifier<M>
impl<M: ManagedTypeApi> TypeAbi for EgldOrEsdtTokenIdentifier<M>
type Unmanaged = EgldOrEsdtTokenIdentifier<M>
fn type_name() -> TypeName
fn type_name_rust() -> TypeName
fn type_names() -> TypeNames
Source§fn provide_type_descriptions<TDC: TypeDescriptionContainer>(
accumulator: &mut TDC,
)
fn provide_type_descriptions<TDC: TypeDescriptionContainer>( accumulator: &mut TDC, )
impl<M: ManagedTypeApi> Eq for EgldOrEsdtTokenIdentifier<M>
impl<M> TypeAbiFrom<&[u8]> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M: ManagedTypeApi> TypeAbiFrom<&EgldOrEsdtTokenIdentifier<M>> for EgldOrEsdtTokenIdentifier<M>
impl<M> TypeAbiFrom<&TestTokenIdentifier<'_>> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TypeAbiFrom<&TokenIdentifier<M>> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TypeAbiFrom<&str> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M: ManagedTypeApi> TypeAbiFrom<EgldOrEsdtTokenIdentifier<M>> for EgldOrEsdtTokenIdentifier<M>
impl<M> TypeAbiFrom<TestTokenIdentifier<'_>> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TypeAbiFrom<TokenIdentifier<M>> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
Auto Trait Implementations§
impl<M> Freeze for EgldOrEsdtTokenIdentifier<M>
impl<M> RefUnwindSafe for EgldOrEsdtTokenIdentifier<M>
impl<M> Send for EgldOrEsdtTokenIdentifier<M>
impl<M> Sync for EgldOrEsdtTokenIdentifier<M>
impl<M> Unpin for EgldOrEsdtTokenIdentifier<M>
impl<M> UnwindSafe for EgldOrEsdtTokenIdentifier<M>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> SCCodec for Twhere
T: TopEncode,
impl<T> SCCodec for Twhere
T: TopEncode,
fn fmt<F>(&self, f: &mut F)where
F: FormatByteReceiver,
Source§impl<T> TopDecodeMulti for Twhere
T: TopDecode,
impl<T> TopDecodeMulti for Twhere
T: TopDecode,
Source§const IS_SINGLE_VALUE: bool = true
const IS_SINGLE_VALUE: bool = true
fn multi_decode_or_handle_err<I, H>(
input: &mut I,
h: H,
) -> Result<T, <H as DecodeErrorHandler>::HandledErr>where
I: TopDecodeMultiInput,
H: DecodeErrorHandler,
fn multi_decode<I>(input: &mut I) -> Result<Self, DecodeError>where
I: TopDecodeMultiInput,
Source§impl<T> TopDecodeMultiLength for T
impl<T> TopDecodeMultiLength for T
Source§impl<T> TopEncodeMulti for Twhere
T: TopEncode,
impl<T> TopEncodeMulti for Twhere
T: TopEncode,
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,
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.