pub struct ConstantData(/* private fields */);
Expand description
This type describes the actual constant data. Note that the bytes stored in this structure are expected to be in little-endian order; this is due to ease-of-use when interacting with WebAssembly values, which are little-endian by design.
Implementations§
Source§impl ConstantData
impl ConstantData
Sourcepub fn append(self, bytes: impl IntoBytes) -> ConstantData
pub fn append(self, bytes: impl IntoBytes) -> ConstantData
Add new bytes to the constant data.
Sourcepub fn expand_to(self, expected_size: usize) -> ConstantData
pub fn expand_to(self, expected_size: usize) -> ConstantData
Expand the size of the constant data to expected_size
number of bytes by adding zeroes
in the high-order byte slots.
Trait Implementations§
Source§impl Clone for ConstantData
impl Clone for ConstantData
Source§fn clone(&self) -> ConstantData
fn clone(&self) -> ConstantData
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 ConstantData
impl Debug for ConstantData
Source§impl Default for ConstantData
impl Default for ConstantData
Source§fn default() -> ConstantData
fn default() -> ConstantData
Returns the “default value” for a type. Read more
Source§impl Display for ConstantData
impl Display for ConstantData
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Print the constant data in hexadecimal format, e.g. 0x000102030405060708090a0b0c0d0e0f. This function will flip the stored order of bytes–little-endian–to the more readable big-endian ordering.
use cranelift_codegen::ir::ConstantData;
let data = ConstantData::from([3, 2, 1, 0, 0].as_ref()); // note the little-endian order
assert_eq!(data.to_string(), "0x0000010203");
Source§impl From<&[u8]> for ConstantData
impl From<&[u8]> for ConstantData
Source§fn from(v: &[u8]) -> ConstantData
fn from(v: &[u8]) -> ConstantData
Converts to this type from the input type.
Source§impl From<V128Imm> for ConstantData
impl From<V128Imm> for ConstantData
Source§fn from(v: V128Imm) -> ConstantData
fn from(v: V128Imm) -> ConstantData
Converts to this type from the input type.
Source§impl FromIterator<u8> for ConstantData
impl FromIterator<u8> for ConstantData
Source§fn from_iter<T>(iter: T) -> ConstantDatawhere
T: IntoIterator<Item = u8>,
fn from_iter<T>(iter: T) -> ConstantDatawhere
T: IntoIterator<Item = u8>,
Creates a value from an iterator. Read more
Source§impl FromStr for ConstantData
impl FromStr for ConstantData
Source§impl Hash for ConstantData
impl Hash for ConstantData
Source§impl PartialEq for ConstantData
impl PartialEq for ConstantData
impl Eq for ConstantData
impl StructuralPartialEq for ConstantData
Auto Trait Implementations§
impl Freeze for ConstantData
impl RefUnwindSafe for ConstantData
impl Send for ConstantData
impl Sync for ConstantData
impl Unpin for ConstantData
impl UnwindSafe for ConstantData
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§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
Compare self to
key
and return true
if they are equal.