pub struct EgldOrEsdtTokenIdentifier<M>where
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> EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
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 egld() -> EgldOrEsdtTokenIdentifier<M>
pub fn egld() -> EgldOrEsdtTokenIdentifier<M>
New instance of the special EGLD token representation.
Sourcepub fn esdt<TI>(token_identifier: TI) -> EgldOrEsdtTokenIdentifier<M>where
TokenIdentifier<M>: From<TI>,
pub fn esdt<TI>(token_identifier: TI) -> EgldOrEsdtTokenIdentifier<M>where
TokenIdentifier<M>: From<TI>,
ESDT instance, containing an ESDT token identifier.
pub fn parse(data: ManagedBuffer<M>) -> EgldOrEsdtTokenIdentifier<M>
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 for EgldOrEsdtTokenIdentifier<M>where
M: Clone + ManagedTypeApi,
impl<M> Clone for EgldOrEsdtTokenIdentifier<M>where
M: Clone + ManagedTypeApi,
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> From<&[u8]> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> From<&[u8]> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
Source§fn from(bytes: &[u8]) -> EgldOrEsdtTokenIdentifier<M>
fn from(bytes: &[u8]) -> EgldOrEsdtTokenIdentifier<M>
Source§impl<M> From<ManagedBuffer<M>> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> From<ManagedBuffer<M>> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
Source§fn from(buffer: ManagedBuffer<M>) -> EgldOrEsdtTokenIdentifier<M>
fn from(buffer: ManagedBuffer<M>) -> EgldOrEsdtTokenIdentifier<M>
Source§impl<M> ManagedType<M> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> ManagedType<M> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
type OwnHandle = <M as HandleTypeInfo>::ManagedBufferHandle
fn get_handle(&self) -> <M as HandleTypeInfo>::ManagedBufferHandle
Source§unsafe fn forget_into_handle(
self,
) -> <EgldOrEsdtTokenIdentifier<M> as ManagedType<M>>::OwnHandle
unsafe fn forget_into_handle( self, ) -> <EgldOrEsdtTokenIdentifier<M> as ManagedType<M>>::OwnHandle
Source§fn transmute_from_handle_ref(
handle_ref: &<M as HandleTypeInfo>::ManagedBufferHandle,
) -> &EgldOrEsdtTokenIdentifier<M>
fn transmute_from_handle_ref( handle_ref: &<M as HandleTypeInfo>::ManagedBufferHandle, ) -> &EgldOrEsdtTokenIdentifier<M>
fn transmute_from_handle_ref_mut( handle_ref: &mut <M as HandleTypeInfo>::ManagedBufferHandle, ) -> &mut EgldOrEsdtTokenIdentifier<M>
fn get_raw_handle(&self) -> i32
fn as_ref(&self) -> ManagedRef<'_, M, Self>
Source§impl<M> ManagedVecItem for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> ManagedVecItem for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
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: &<EgldOrEsdtTokenIdentifier<M> as ManagedVecItem>::PAYLOAD,
) -> EgldOrEsdtTokenIdentifier<M>
fn read_from_payload( payload: &<EgldOrEsdtTokenIdentifier<M> as ManagedVecItem>::PAYLOAD, ) -> EgldOrEsdtTokenIdentifier<M>
Source§unsafe fn borrow_from_payload<'a>(
payload: &<EgldOrEsdtTokenIdentifier<M> as ManagedVecItem>::PAYLOAD,
) -> <EgldOrEsdtTokenIdentifier<M> as ManagedVecItem>::Ref<'a>
unsafe fn borrow_from_payload<'a>( payload: &<EgldOrEsdtTokenIdentifier<M> as ManagedVecItem>::PAYLOAD, ) -> <EgldOrEsdtTokenIdentifier<M> as ManagedVecItem>::Ref<'a>
Source§fn save_to_payload(
self,
payload: &mut <EgldOrEsdtTokenIdentifier<M> as ManagedVecItem>::PAYLOAD,
)
fn save_to_payload( self, payload: &mut <EgldOrEsdtTokenIdentifier<M> as ManagedVecItem>::PAYLOAD, )
fn payload_size() -> usize
Source§impl<M> NestedDecode for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> NestedDecode for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
Source§fn dep_decode_or_handle_err<I, H>(
input: &mut I,
h: H,
) -> Result<EgldOrEsdtTokenIdentifier<M>, <H as DecodeErrorHandler>::HandledErr>where
I: NestedDecodeInput,
H: DecodeErrorHandler,
fn dep_decode_or_handle_err<I, H>(
input: &mut I,
h: H,
) -> Result<EgldOrEsdtTokenIdentifier<M>, <H as DecodeErrorHandler>::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> NestedEncode for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> NestedEncode for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
Source§fn dep_encode_or_handle_err<O, H>(
&self,
dest: &mut O,
h: H,
) -> Result<(), <H as EncodeErrorHandler>::HandledErr>where
O: NestedEncodeOutput,
H: EncodeErrorHandler,
fn dep_encode_or_handle_err<O, H>(
&self,
dest: &mut O,
h: H,
) -> Result<(), <H as EncodeErrorHandler>::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> PartialEq<EgldOrEsdtTokenIdentifier<M>> for TokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> PartialEq<EgldOrEsdtTokenIdentifier<M>> for TokenIdentifier<M>where
M: ManagedTypeApi,
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> PartialEq<TokenIdentifier<M>> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> PartialEq<TokenIdentifier<M>> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
Source§impl<M> PartialEq for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> PartialEq for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
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> SCDisplay for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> SCDisplay for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
fn fmt<F>(&self, f: &mut F)where
F: FormatByteReceiver,
Source§impl<M> SCLowerHex for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> SCLowerHex for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
fn fmt<F>(&self, f: &mut F)where
F: FormatByteReceiver,
Source§impl<M> TopDecode for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TopDecode for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
Source§fn top_decode_or_handle_err<I, H>(
input: I,
h: H,
) -> Result<EgldOrEsdtTokenIdentifier<M>, <H as DecodeErrorHandler>::HandledErr>where
I: TopDecodeInput,
H: DecodeErrorHandler,
fn top_decode_or_handle_err<I, H>(
input: I,
h: H,
) -> Result<EgldOrEsdtTokenIdentifier<M>, <H as DecodeErrorHandler>::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> TopEncode for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TopEncode for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
Source§fn top_encode_or_handle_err<O, H>(
&self,
output: O,
h: H,
) -> Result<(), <H as EncodeErrorHandler>::HandledErr>where
O: TopEncodeOutput,
H: EncodeErrorHandler,
fn top_encode_or_handle_err<O, H>(
&self,
output: O,
h: H,
) -> Result<(), <H as EncodeErrorHandler>::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> TypeAbi for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TypeAbi for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
type Unmanaged = EgldOrEsdtTokenIdentifier<M>
fn type_name() -> String
fn type_name_rust() -> String
fn type_names() -> TypeNames
Source§fn provide_type_descriptions<TDC>(accumulator: &mut TDC)where
TDC: TypeDescriptionContainer,
fn provide_type_descriptions<TDC>(accumulator: &mut TDC)where
TDC: TypeDescriptionContainer,
impl<M> Eq for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TypeAbiFrom<&[u8]> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TypeAbiFrom<&EgldOrEsdtTokenIdentifier<M>> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
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> TypeAbiFrom<EgldOrEsdtTokenIdentifier<M>> for EgldOrEsdtTokenIdentifier<M>where
M: ManagedTypeApi,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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> 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>
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>
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 moreSource§impl<T> ReconstructableFrom<&T> for Twhere
T: Clone,
impl<T> ReconstructableFrom<&T> for Twhere
T: Clone,
fn reconstruct_from(from: &T, _builder: &ReconstructorContext) -> T
Source§impl<T> ReconstructableFrom<T> for T
impl<T> ReconstructableFrom<T> for T
fn reconstruct_from(from: T, _builder: &ReconstructorContext) -> T
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.