Struct dharitri_wasm::types::TokenIdentifier
source · pub struct TokenIdentifier<M: ManagedTypeApi> { /* private fields */ }
Expand description
Specialized type for handling token identifiers. It wraps a BoxedBytes with the full ASCII name of the token. MOAX is stored as an empty name.
Not yet implemented, but we might add additional restrictions when deserializing as argument.
Implementations§
source§impl<M: ManagedTypeApi> TokenIdentifier<M>
impl<M: ManagedTypeApi> TokenIdentifier<M>
sourcepub const MOAX_REPRESENTATION: &'static [u8; 4] = _
pub const MOAX_REPRESENTATION: &'static [u8; 4] = _
This special representation is interpreted as the MOAX token.
pub const TICKER_MIN_LENGTH: usize = 3usize
pub const TICKER_MAX_LENGTH: usize = 10usize
pub const ADDITIONAL_RANDOM_CHARS_LENGTH: usize = 6usize
pub const IDENTIFIER_MIN_LENGTH: usize = 10usize
pub const IDENTIFIER_MAX_LENGTH: usize = 17usize
pub const DASH_CHARACTER: u8 = 45u8
pub fn from_dct_bytes<B: ManagedInto<M, ManagedBuffer<M>>>( api: M, bytes: B ) -> Self
pub fn is_moax(&self) -> bool
pub fn is_dct(&self) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn into_managed_buffer(self) -> ManagedBuffer<M>
pub fn as_managed_buffer(&self) -> &ManagedBuffer<M>
pub fn to_dct_identifier(&self) -> BoxedBytes
pub fn as_name(&self) -> BoxedBytes
pub fn is_valid_dct_identifier(&self) -> bool
Trait Implementations§
source§impl<M: Clone + ManagedTypeApi> Clone for TokenIdentifier<M>
impl<M: Clone + ManagedTypeApi> Clone for TokenIdentifier<M>
source§fn clone(&self) -> TokenIdentifier<M>
fn clone(&self) -> TokenIdentifier<M>
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<M: Debug + ManagedTypeApi> Debug for TokenIdentifier<M>
impl<M: Debug + ManagedTypeApi> Debug for TokenIdentifier<M>
source§impl<M: ManagedTypeApi> From<ManagedBuffer<M>> for TokenIdentifier<M>
impl<M: ManagedTypeApi> From<ManagedBuffer<M>> for TokenIdentifier<M>
source§fn from(buffer: ManagedBuffer<M>) -> Self
fn from(buffer: ManagedBuffer<M>) -> Self
Converts to this type from the input type.
source§impl<M: ManagedTypeApi> ManagedFrom<M, &[u8]> for TokenIdentifier<M>
impl<M: ManagedTypeApi> ManagedFrom<M, &[u8]> for TokenIdentifier<M>
fn managed_from(api: M, bytes: &[u8]) -> Self
source§impl<M: ManagedTypeApi> ManagedFrom<M, ManagedBuffer<M>> for TokenIdentifier<M>
impl<M: ManagedTypeApi> ManagedFrom<M, ManagedBuffer<M>> for TokenIdentifier<M>
fn managed_from(_: M, buffer: ManagedBuffer<M>) -> Self
source§impl<M: ManagedTypeApi> ManagedType<M> for TokenIdentifier<M>
impl<M: ManagedTypeApi> ManagedType<M> for TokenIdentifier<M>
fn type_manager(&self) -> M
source§impl<M: ManagedTypeApi> ManagedVecItem<M> for TokenIdentifier<M>
impl<M: ManagedTypeApi> ManagedVecItem<M> for TokenIdentifier<M>
source§const PAYLOAD_SIZE: usize = 4usize
const PAYLOAD_SIZE: usize = 4usize
Size of the data stored in the underlying
ManagedBuffer
.source§const NEEDS_RESERIALIZATION: bool = true
const NEEDS_RESERIALIZATION: bool = true
If false, then the encoding of the item is identical to the payload,
and no further conversion is necessary
(the underlying buffer can be used as-is during serialization).
True for all managed types, but false for basic types (like
u32
).fn from_byte_reader<Reader: FnMut(&mut [u8])>(api: M, reader: Reader) -> Self
fn to_byte_writer<R, Writer: FnMut(&[u8]) -> R>(&self, writer: Writer) -> R
source§impl<M: ManagedTypeApi> NestedDecode for TokenIdentifier<M>
impl<M: ManagedTypeApi> NestedDecode for TokenIdentifier<M>
source§fn dep_decode<I: NestedDecodeInput>(input: &mut I) -> Result<Self, DecodeError>
fn dep_decode<I: NestedDecodeInput>(input: &mut I) -> Result<Self, DecodeError>
Attempt to deserialise the value from input,
using the format of an object nested inside another structure.
In case of success returns the deserialized value and the number of bytes consumed during the operation.
source§fn dep_decode_or_exit<I: NestedDecodeInput, ExitCtx: Clone>(
input: &mut I,
c: ExitCtx,
exit: fn(_: ExitCtx, _: DecodeError) -> !
) -> Self
fn dep_decode_or_exit<I: NestedDecodeInput, ExitCtx: Clone>( input: &mut I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self
Version of
top_decode
that exits quickly in case of error.
Its purpose is to create smaller implementations
in cases where the application is supposed to exit directly on decode error.source§impl<M: ManagedTypeApi> NestedEncode for TokenIdentifier<M>
impl<M: ManagedTypeApi> NestedEncode for TokenIdentifier<M>
source§fn dep_encode<O: NestedEncodeOutput>(
&self,
dest: &mut O
) -> Result<(), EncodeError>
fn dep_encode<O: NestedEncodeOutput>( &self, dest: &mut O ) -> Result<(), EncodeError>
NestedEncode to output, using the format of an object nested inside another structure.
Does not provide compact version.
source§fn dep_encode_or_exit<O, ExitCtx>(
&self,
dest: &mut O,
c: ExitCtx,
exit: fn(_: ExitCtx, _: EncodeError) -> !
)where
O: NestedEncodeOutput,
ExitCtx: Clone,
fn dep_encode_or_exit<O, ExitCtx>(
&self,
dest: &mut O,
c: ExitCtx,
exit: fn(_: ExitCtx, _: EncodeError) -> !
)where
O: NestedEncodeOutput,
ExitCtx: Clone,
Version of
top_decode
that exits quickly in case of error.
Its purpose is to create smaller implementations
in cases where the application is supposed to exit directly on decode error.source§impl<M: ManagedTypeApi> PartialEq for TokenIdentifier<M>
impl<M: ManagedTypeApi> PartialEq for TokenIdentifier<M>
source§impl<M: ManagedTypeApi> TopDecode for TokenIdentifier<M>
impl<M: ManagedTypeApi> TopDecode for TokenIdentifier<M>
source§fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>
fn top_decode<I: TopDecodeInput>(input: I) -> Result<Self, DecodeError>
Attempt to deserialize the value from input.
source§fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>(
input: I,
c: ExitCtx,
exit: fn(_: ExitCtx, _: DecodeError) -> !
) -> Self
fn top_decode_or_exit<I: TopDecodeInput, ExitCtx: Clone>( input: I, c: ExitCtx, exit: fn(_: ExitCtx, _: DecodeError) -> ! ) -> Self
Version of
top_decode
that exits quickly in case of error.
Its purpose is to create smaller implementations
in cases where the application is supposed to exit directly on decode error.source§impl<M: ManagedTypeApi> TopEncode for TokenIdentifier<M>
impl<M: ManagedTypeApi> TopEncode for TokenIdentifier<M>
source§fn top_encode<O: TopEncodeOutput>(&self, output: O) -> Result<(), EncodeError>
fn top_encode<O: TopEncodeOutput>(&self, output: O) -> Result<(), EncodeError>
Attempt to serialize the value to ouput.
source§fn top_encode_or_exit<O, ExitCtx>(
&self,
output: O,
c: ExitCtx,
exit: fn(_: ExitCtx, _: EncodeError) -> !
)where
O: TopEncodeOutput,
ExitCtx: Clone,
fn top_encode_or_exit<O, ExitCtx>(
&self,
output: O,
c: ExitCtx,
exit: fn(_: ExitCtx, _: EncodeError) -> !
)where
O: TopEncodeOutput,
ExitCtx: Clone,
Version of
top_decode
that exits quickly in case of error.
Its purpose is to create smaller bytecode implementations
in cases where the application is supposed to exit directly on decode error.source§impl<M: ManagedTypeApi> TypeAbi for TokenIdentifier<M>
impl<M: ManagedTypeApi> TypeAbi for TokenIdentifier<M>
fn type_name() -> String
source§fn provide_type_descriptions<TDC: TypeDescriptionContainer>(
accumulator: &mut TDC
)
fn provide_type_descriptions<TDC: TypeDescriptionContainer>( accumulator: &mut TDC )
A type can provide more than its own description.
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.
impl<M: ManagedTypeApi> Eq for TokenIdentifier<M>
Auto Trait Implementations§
impl<M> RefUnwindSafe for TokenIdentifier<M>where
M: RefUnwindSafe,
impl<M> Send for TokenIdentifier<M>where
M: Send,
impl<M> Sync for TokenIdentifier<M>where
M: Sync,
impl<M> Unpin for TokenIdentifier<M>where
M: Unpin,
impl<M> UnwindSafe for TokenIdentifier<M>where
M: UnwindSafe,
Blanket Implementations§
source§impl<M, T> AsManagedRef<M, T> for Twhere
M: ManagedTypeApi,
T: ManagedType<M>,
impl<M, T> AsManagedRef<M, T> for Twhere
M: ManagedTypeApi,
T: ManagedType<M>,
fn as_managed_ref(&self) -> ManagedRef<M, T>
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