pub struct RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,{ /* private fields */ }
Expand description
Specialized type for handling either REWA or DCDT token identifiers.
Equivalent to a structure of the form
enum RewaOrDcdtTokenIdentifier<M: ManagedTypeApi> {
Rewa,
Dcdt(TokenIdentifier<M>),
}
It is, however more optimized than that. Its implementation is based on ManagedOption
.
REWA a special, invalid token identifier handle. This way we can fit it inside a single i32 in memory.
Implementations§
Source§impl<M> RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
Sourcepub const REWA_REPRESENTATION: &'static [u8; 4]
pub const REWA_REPRESENTATION: &'static [u8; 4]
This special representation is interpreted as the REWA token.
Sourcepub fn rewa() -> RewaOrDcdtTokenIdentifier<M>
pub fn rewa() -> RewaOrDcdtTokenIdentifier<M>
New instance of the special REWA token representation.
Sourcepub fn dcdt<TI>(token_identifier: TI) -> RewaOrDcdtTokenIdentifier<M>where
TokenIdentifier<M>: From<TI>,
pub fn dcdt<TI>(token_identifier: TI) -> RewaOrDcdtTokenIdentifier<M>where
TokenIdentifier<M>: From<TI>,
DCDT instance, containing an DCDT token identifier.
pub fn from_opt_raw_handle( opt_handle: Option<<M as HandleTypeInfo>::ManagedBufferHandle>, ) -> RewaOrDcdtTokenIdentifier<M>
pub fn parse(data: ManagedBuffer<M>) -> RewaOrDcdtTokenIdentifier<M>
pub fn is_rewa(&self) -> bool
pub fn is_dcdt(&self) -> bool
pub fn into_name(self) -> ManagedBuffer<M>
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Checks the DCDT token identifier for validity. REWA is considered valid, no checks needed.
Will fail if it encodes an invalid DCDT token identifier.
pub fn map_or_else<Context, D, F, R>( self, context: Context, for_rewa: D, for_dcdt: F, ) -> R
pub fn map_ref_or_else<Context, D, F, R>( &self, context: Context, for_rewa: D, for_dcdt: F, ) -> R
pub fn unwrap_dcdt(self) -> TokenIdentifier<M>
Sourcepub fn as_dcdt_option(&self) -> Option<ManagedRef<'_, M, TokenIdentifier<M>>>
pub fn as_dcdt_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 DCDT token identifier can be returned.
Sourcepub fn into_dcdt_option(self) -> Option<TokenIdentifier<M>>
pub fn into_dcdt_option(self) -> Option<TokenIdentifier<M>>
Converts self
into an Option
. Consumes self
in the process.
Trait Implementations§
Source§impl<M> Clone for RewaOrDcdtTokenIdentifier<M>where
M: Clone + ManagedTypeApi,
impl<M> Clone for RewaOrDcdtTokenIdentifier<M>where
M: Clone + ManagedTypeApi,
Source§fn clone(&self) -> RewaOrDcdtTokenIdentifier<M>
fn clone(&self) -> RewaOrDcdtTokenIdentifier<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 RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> Debug for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
Source§impl<M> ManagedVecItem for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> ManagedVecItem for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
Source§const SKIPS_RESERIALIZATION: bool = false
const SKIPS_RESERIALIZATION: bool = false
u32
).Source§type PAYLOAD = <(ManagedOption<M, TokenIdentifier<M>>, ()) as ManagedVecItemNestedTuple>::PAYLOAD
type PAYLOAD = <(ManagedOption<M, TokenIdentifier<M>>, ()) as ManagedVecItemNestedTuple>::PAYLOAD
Source§type Ref<'a> = RewaOrDcdtTokenIdentifier<M>
type Ref<'a> = RewaOrDcdtTokenIdentifier<M>
Source§fn from_byte_reader<Reader>(reader: Reader) -> RewaOrDcdtTokenIdentifier<M>
fn from_byte_reader<Reader>(reader: Reader) -> RewaOrDcdtTokenIdentifier<M>
Source§unsafe fn from_byte_reader_as_borrow<'a, Reader>(
reader: Reader,
) -> <RewaOrDcdtTokenIdentifier<M> as ManagedVecItem>::Ref<'a>
unsafe fn from_byte_reader_as_borrow<'a, Reader>( reader: Reader, ) -> <RewaOrDcdtTokenIdentifier<M> as ManagedVecItem>::Ref<'a>
fn to_byte_writer<R, Writer>(&self, writer: Writer) -> R
fn payload_size() -> usize
Source§impl<M> NestedDecode for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> NestedDecode for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
Source§fn dep_decode_or_handle_err<I, H>(
input: &mut I,
h: H,
) -> Result<RewaOrDcdtTokenIdentifier<M>, <H as DecodeErrorHandler>::HandledErr>where
I: NestedDecodeInput,
H: DecodeErrorHandler,
fn dep_decode_or_handle_err<I, H>(
input: &mut I,
h: H,
) -> Result<RewaOrDcdtTokenIdentifier<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 RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> NestedEncode for RewaOrDcdtTokenIdentifier<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<RewaOrDcdtTokenIdentifier<M>> for TokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> PartialEq<RewaOrDcdtTokenIdentifier<M>> for TokenIdentifier<M>where
M: ManagedTypeApi,
Source§fn eq(&self, other: &RewaOrDcdtTokenIdentifier<M>) -> bool
fn eq(&self, other: &RewaOrDcdtTokenIdentifier<M>) -> bool
self
and other
values to be equal, and is used by ==
.Source§impl<M> PartialEq<TokenIdentifier<M>> for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> PartialEq<TokenIdentifier<M>> for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
Source§impl<M> PartialEq for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> PartialEq for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
Source§fn eq(&self, other: &RewaOrDcdtTokenIdentifier<M>) -> bool
fn eq(&self, other: &RewaOrDcdtTokenIdentifier<M>) -> bool
self
and other
values to be equal, and is used by ==
.Source§impl<M> SCDisplay for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> SCDisplay for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
fn fmt<F>(&self, f: &mut F)where
F: FormatByteReceiver,
Source§impl<M> SCLowerHex for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> SCLowerHex for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
fn fmt<F>(&self, f: &mut F)where
F: FormatByteReceiver,
Source§impl<M> TopDecode for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TopDecode for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
Source§fn top_decode_or_handle_err<I, H>(
input: I,
h: H,
) -> Result<RewaOrDcdtTokenIdentifier<M>, <H as DecodeErrorHandler>::HandledErr>where
I: TopDecodeInput,
H: DecodeErrorHandler,
fn top_decode_or_handle_err<I, H>(
input: I,
h: H,
) -> Result<RewaOrDcdtTokenIdentifier<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 RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TopEncode for RewaOrDcdtTokenIdentifier<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 RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TypeAbi for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
type Unmanaged = RewaOrDcdtTokenIdentifier<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 RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TypeAbiFrom<&[u8]> for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TypeAbiFrom<&RewaOrDcdtTokenIdentifier<M>> for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<'a, M> TypeAbiFrom<&TestTokenIdentifier<'a>> for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TypeAbiFrom<&TokenIdentifier<M>> for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TypeAbiFrom<&str> for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TypeAbiFrom<RewaOrDcdtTokenIdentifier<M>> for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<'a, M> TypeAbiFrom<TestTokenIdentifier<'a>> for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
impl<M> TypeAbiFrom<TokenIdentifier<M>> for RewaOrDcdtTokenIdentifier<M>where
M: ManagedTypeApi,
Auto Trait Implementations§
impl<M> Freeze for RewaOrDcdtTokenIdentifier<M>
impl<M> RefUnwindSafe for RewaOrDcdtTokenIdentifier<M>
impl<M> Send for RewaOrDcdtTokenIdentifier<M>
impl<M> Sync for RewaOrDcdtTokenIdentifier<M>
impl<M> Unpin for RewaOrDcdtTokenIdentifier<M>
impl<M> UnwindSafe for RewaOrDcdtTokenIdentifier<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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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.