wiggle::wasmtime_crate::component

Struct WasmList

pub struct WasmList<T> { /* private fields */ }
Expand description

Representation of a list of values that are owned by a WebAssembly instance.

For some more commentary about the rationale for this type see the documentation of WasmStr. In summary this type can avoid a copy when passing data to the host in some situations but is additionally more cumbersome to use by requiring a Store to be provided.

This type is used whenever a (list T) is returned from a TypedFunc, for example. This type represents a list of values that are stored in linear memory which are waiting to be read.

Note that this type represents only a valid range of bytes for the list itself, it does not represent validity of the elements themselves and that’s performed when they’re iterated.

Note that this type does not implement the Lower trait, only Lift.

Implementations§

§

impl<T> WasmList<T>
where T: Lift,

pub fn len(&self) -> usize

Returns the item length of this vector

pub fn get( &self, store: impl AsContextMut, index: usize, ) -> Option<Result<T, Error>>

Gets the nth element of this list.

Returns None if index is out of bounds. Returns Some(Err(..)) if the value couldn’t be decoded (it was invalid). Returns Some(Ok(..)) if the value is valid.

§Panics

This function will panic if the string did not originally come from the store specified.

pub fn iter<'a, U>( &'a self, store: impl Into<StoreContextMut<'a, U>>, ) -> impl ExactSizeIterator + 'a
where U: 'a,

Returns an iterator over the elements of this list.

Each item of the list may fail to decode and is represented through the Result value of the iterator.

§

impl WasmList<i8>

pub fn as_le_slice<'a, T>( &self, store: impl Into<StoreContext<'a, T>>, ) -> &'a [i8]
where T: 'a,

Get access to the raw underlying memory for this list.

This method will return a direct slice into the original wasm module’s linear memory where the data for this slice is stored. This allows the embedder to have efficient access to the underlying memory if needed and avoid copies and such if desired.

Note that multi-byte integers are stored in little-endian format so portable processing of this slice must be aware of the host’s byte-endianness. The from_le constructors in the Rust standard library should be suitable for converting from little-endian.

§Panics

Panics if the store provided is not the one from which this slice originated.

§

impl WasmList<i16>

pub fn as_le_slice<'a, T>( &self, store: impl Into<StoreContext<'a, T>>, ) -> &'a [i16]
where T: 'a,

Get access to the raw underlying memory for this list.

This method will return a direct slice into the original wasm module’s linear memory where the data for this slice is stored. This allows the embedder to have efficient access to the underlying memory if needed and avoid copies and such if desired.

Note that multi-byte integers are stored in little-endian format so portable processing of this slice must be aware of the host’s byte-endianness. The from_le constructors in the Rust standard library should be suitable for converting from little-endian.

§Panics

Panics if the store provided is not the one from which this slice originated.

§

impl WasmList<i32>

pub fn as_le_slice<'a, T>( &self, store: impl Into<StoreContext<'a, T>>, ) -> &'a [i32]
where T: 'a,

Get access to the raw underlying memory for this list.

This method will return a direct slice into the original wasm module’s linear memory where the data for this slice is stored. This allows the embedder to have efficient access to the underlying memory if needed and avoid copies and such if desired.

Note that multi-byte integers are stored in little-endian format so portable processing of this slice must be aware of the host’s byte-endianness. The from_le constructors in the Rust standard library should be suitable for converting from little-endian.

§Panics

Panics if the store provided is not the one from which this slice originated.

§

impl WasmList<i64>

pub fn as_le_slice<'a, T>( &self, store: impl Into<StoreContext<'a, T>>, ) -> &'a [i64]
where T: 'a,

Get access to the raw underlying memory for this list.

This method will return a direct slice into the original wasm module’s linear memory where the data for this slice is stored. This allows the embedder to have efficient access to the underlying memory if needed and avoid copies and such if desired.

Note that multi-byte integers are stored in little-endian format so portable processing of this slice must be aware of the host’s byte-endianness. The from_le constructors in the Rust standard library should be suitable for converting from little-endian.

§Panics

Panics if the store provided is not the one from which this slice originated.

§

impl WasmList<u8>

pub fn as_le_slice<'a, T>( &self, store: impl Into<StoreContext<'a, T>>, ) -> &'a [u8]
where T: 'a,

Get access to the raw underlying memory for this list.

This method will return a direct slice into the original wasm module’s linear memory where the data for this slice is stored. This allows the embedder to have efficient access to the underlying memory if needed and avoid copies and such if desired.

Note that multi-byte integers are stored in little-endian format so portable processing of this slice must be aware of the host’s byte-endianness. The from_le constructors in the Rust standard library should be suitable for converting from little-endian.

§Panics

Panics if the store provided is not the one from which this slice originated.

§

impl WasmList<u16>

pub fn as_le_slice<'a, T>( &self, store: impl Into<StoreContext<'a, T>>, ) -> &'a [u16]
where T: 'a,

Get access to the raw underlying memory for this list.

This method will return a direct slice into the original wasm module’s linear memory where the data for this slice is stored. This allows the embedder to have efficient access to the underlying memory if needed and avoid copies and such if desired.

Note that multi-byte integers are stored in little-endian format so portable processing of this slice must be aware of the host’s byte-endianness. The from_le constructors in the Rust standard library should be suitable for converting from little-endian.

§Panics

Panics if the store provided is not the one from which this slice originated.

§

impl WasmList<u32>

pub fn as_le_slice<'a, T>( &self, store: impl Into<StoreContext<'a, T>>, ) -> &'a [u32]
where T: 'a,

Get access to the raw underlying memory for this list.

This method will return a direct slice into the original wasm module’s linear memory where the data for this slice is stored. This allows the embedder to have efficient access to the underlying memory if needed and avoid copies and such if desired.

Note that multi-byte integers are stored in little-endian format so portable processing of this slice must be aware of the host’s byte-endianness. The from_le constructors in the Rust standard library should be suitable for converting from little-endian.

§Panics

Panics if the store provided is not the one from which this slice originated.

§

impl WasmList<u64>

pub fn as_le_slice<'a, T>( &self, store: impl Into<StoreContext<'a, T>>, ) -> &'a [u64]
where T: 'a,

Get access to the raw underlying memory for this list.

This method will return a direct slice into the original wasm module’s linear memory where the data for this slice is stored. This allows the embedder to have efficient access to the underlying memory if needed and avoid copies and such if desired.

Note that multi-byte integers are stored in little-endian format so portable processing of this slice must be aware of the host’s byte-endianness. The from_le constructors in the Rust standard library should be suitable for converting from little-endian.

§Panics

Panics if the store provided is not the one from which this slice originated.

Trait Implementations§

§

impl<T> ComponentType for WasmList<T>
where T: ComponentType,

§

impl<T> Lift for WasmList<T>
where T: Lift,

Auto Trait Implementations§

§

impl<T> Freeze for WasmList<T>

§

impl<T> !RefUnwindSafe for WasmList<T>

§

impl<T> Send for WasmList<T>
where T: Send,

§

impl<T> Sync for WasmList<T>
where T: Sync,

§

impl<T> Unpin for WasmList<T>
where T: Unpin,

§

impl<T> !UnwindSafe for WasmList<T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Pointee for T

source§

type Pointer = u32

source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_>, ) -> Result<(), Error>

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more