pub struct ConstantData(_);
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

Return the number of bytes in the constant.

Check if the constant contains any bytes.

Return the data as a slice.

Convert the data to a vector.

Iterate over the constant’s bytes.

Add new bytes to the constant data.

Expand the size of the constant data to expected_size number of bytes by adding zeroes in the high-order byte slots.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

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");

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Creates a value from an iterator. Read more

Parse a hexadecimal string to ConstantData. This is the inverse of Display::fmt.

use cranelift_codegen::ir::ConstantData;
let c: ConstantData = "0x000102".parse().unwrap();
assert_eq!(c.into_vec(), [2, 1, 0]);

The associated error which can be returned from parsing.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.