pub enum StackValue {
Uint(u64),
Bytes(Vec<u8>),
}
Expand description
Stack value type that can hold different types of data
Variants§
Uint(u64)
Unsigned 64-bit integer
Bytes(Vec<u8>)
Byte array (used for addresses, hashes, strings, etc.)
Implementations§
Source§impl StackValue
impl StackValue
Sourcepub fn from_string(s: &str) -> Self
pub fn from_string(s: &str) -> Self
Create a new bytes value from a string
Sourcepub fn as_uint(&self) -> Result<u64, AvmError>
pub fn as_uint(&self) -> Result<u64, AvmError>
Get the uint value, returning an error if not a uint
Sourcepub fn as_bytes(&self) -> Result<&[u8], AvmError>
pub fn as_bytes(&self) -> Result<&[u8], AvmError>
Get the bytes value, returning an error if not bytes
Sourcepub fn as_bytes_mut(&mut self) -> Result<&mut Vec<u8>, AvmError>
pub fn as_bytes_mut(&mut self) -> Result<&mut Vec<u8>, AvmError>
Get the bytes value as a mutable reference
Sourcepub fn uint_or_zero(&self) -> u64
pub fn uint_or_zero(&self) -> u64
Convert to uint if possible, otherwise return 0
Trait Implementations§
Source§impl Clone for StackValue
impl Clone for StackValue
Source§fn clone(&self) -> StackValue
fn clone(&self) -> StackValue
Returns a duplicate 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 Debug for StackValue
impl Debug for StackValue
Source§impl<'de> Deserialize<'de> for StackValue
impl<'de> Deserialize<'de> for StackValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for StackValue
impl Display for StackValue
Source§impl From<&[u8]> for StackValue
impl From<&[u8]> for StackValue
Source§impl From<&str> for StackValue
impl From<&str> for StackValue
Source§impl From<String> for StackValue
impl From<String> for StackValue
Source§impl From<u64> for StackValue
impl From<u64> for StackValue
Source§impl PartialEq for StackValue
impl PartialEq for StackValue
Source§impl Serialize for StackValue
impl Serialize for StackValue
impl StructuralPartialEq for StackValue
Auto Trait Implementations§
impl Freeze for StackValue
impl RefUnwindSafe for StackValue
impl Send for StackValue
impl Sync for StackValue
impl Unpin for StackValue
impl UnwindSafe for StackValue
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