pub struct Encoder { /* private fields */ }
Expand description
An ABI encoder.
This is not intended for public consumption. It should be used only by the
token types. If you have found yourself here, you probably want to use the
high-level crate::SolType
interface (or its dynamic equivalent) instead.
Implementations§
Source§impl Encoder
impl Encoder
Sourcepub fn with_capacity(size: usize) -> Self
pub fn with_capacity(size: usize) -> Self
Instantiate a new encoder with a given capacity in words.
Sourcepub fn finish(self) -> Vec<Word>
pub fn finish(self) -> Vec<Word>
Finish the encoding process, returning the encoded words.
Use into_bytes
instead to flatten the words into bytes.
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Finish the encoding process, returning the encoded bytes.
Sourcepub fn suffix_offset(&self) -> usize
pub fn suffix_offset(&self) -> usize
Sourcepub fn push_offset(&mut self, words: usize)
pub fn push_offset(&mut self, words: usize)
Appends a suffix offset.
Sourcepub fn pop_offset(&mut self) -> Option<usize>
pub fn pop_offset(&mut self) -> Option<usize>
Removes the last offset and returns it.
Sourcepub fn bump_offset(&mut self, words: usize)
pub fn bump_offset(&mut self, words: usize)
Bump the suffix offset by a given number of words.
Sourcepub fn append_word(&mut self, word: Word)
pub fn append_word(&mut self, word: Word)
Append a word to the encoder.
Sourcepub fn append_indirection(&mut self)
pub fn append_indirection(&mut self)
Sourcepub fn append_seq_len(&mut self, len: usize)
pub fn append_seq_len(&mut self, len: usize)
Append a sequence length.
Sourcepub fn append_packed_seq(&mut self, bytes: &[u8])
pub fn append_packed_seq(&mut self, bytes: &[u8])
Append a sequence of bytes as a packed sequence with a length prefix.
Sourcepub fn append_head_tail<'a, T: TokenSeq<'a>>(&mut self, token: &T)
pub fn append_head_tail<'a, T: TokenSeq<'a>>(&mut self, token: &T)
Shortcut for appending a token sequence.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Encoder
impl RefUnwindSafe for Encoder
impl Send for Encoder
impl Sync for Encoder
impl Unpin for Encoder
impl UnwindSafe for Encoder
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)