pub enum DynToken<'a> {
Word(Word),
FixedSeq(Cow<'a, [DynToken<'a>]>, usize),
DynSeq {
contents: Cow<'a, [DynToken<'a>]>,
/* private fields */
},
PackedSeq(&'a [u8]),
}
Expand description
A dynamic token.
Equivalent to an enum over all types implementing Token
.
Variants§
Word(Word)
A single word.
FixedSeq(Cow<'a, [DynToken<'a>]>, usize)
A Fixed Sequence.
DynSeq
A dynamic-length sequence.
PackedSeq(&'a [u8])
A packed sequence (string or bytes).
Implementations§
Source§impl<'a> DynToken<'a>
impl<'a> DynToken<'a>
Sourcepub fn minimum_words(&self) -> usize
pub fn minimum_words(&self) -> usize
Calculate the minimum number of words required to encode this token.
Sourcepub fn from_fixed_seq(seq: &'a [DynSolValue]) -> Self
pub fn from_fixed_seq(seq: &'a [DynSolValue]) -> Self
Instantiate a DynToken from a fixed sequence of values.
Sourcepub fn from_dyn_seq(seq: &'a [DynSolValue]) -> Self
pub fn from_dyn_seq(seq: &'a [DynSolValue]) -> Self
Instantiate a DynToken from a dynamic sequence of values.
Sourcepub fn as_fixed_seq(&self) -> Option<(&[Self], usize)>
pub fn as_fixed_seq(&self) -> Option<(&[Self], usize)>
Fallible cast into a fixed sequence.
Sourcepub fn as_dynamic_seq(&self) -> Option<&[Self]>
pub fn as_dynamic_seq(&self) -> Option<&[Self]>
Fallible cast into a dynamic sequence.
Sourcepub fn as_token_seq(&self) -> Option<&[Self]>
pub fn as_token_seq(&self) -> Option<&[Self]>
Fallible cast into a sequence, dynamic or fixed-size
Sourcepub const fn as_packed_seq(&self) -> Option<&[u8]>
pub const fn as_packed_seq(&self) -> Option<&[u8]>
Fallible cast into a packed sequence.
Sourcepub fn is_dynamic(&self) -> bool
pub fn is_dynamic(&self) -> bool
True if the type is dynamic, else false.
Trait Implementations§
impl Eq for DynToken<'_>
Auto Trait Implementations§
impl<'a> Freeze for DynToken<'a>
impl<'a> RefUnwindSafe for DynToken<'a>
impl<'a> Send for DynToken<'a>
impl<'a> Sync for DynToken<'a>
impl<'a> Unpin for DynToken<'a>
impl<'a> UnwindSafe for DynToken<'a>
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,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 36 bytes
Size for each variant:
Word
: 32 bytesFixedSeq
: 19 bytesDynSeq
: 19 bytesPackedSeq
: 11 bytes