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,
impl<T> WasmList<T>where
T: Lift,
pub fn get(
&self,
store: impl AsContextMut,
index: usize,
) -> Option<Result<T, Error>>
pub fn get( &self, store: impl AsContextMut, index: usize, ) -> Option<Result<T, Error>>
Gets the n
th 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 + 'awhere
U: 'a,
pub fn iter<'a, U>(
&'a self,
store: impl Into<StoreContextMut<'a, U>>,
) -> impl ExactSizeIterator + 'awhere
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>
impl WasmList<i8>
pub fn as_le_slice<'a, T>(
&self,
store: impl Into<StoreContext<'a, T>>,
) -> &'a [i8]where
T: 'a,
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>
impl WasmList<i16>
pub fn as_le_slice<'a, T>(
&self,
store: impl Into<StoreContext<'a, T>>,
) -> &'a [i16]where
T: 'a,
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>
impl WasmList<i32>
pub fn as_le_slice<'a, T>(
&self,
store: impl Into<StoreContext<'a, T>>,
) -> &'a [i32]where
T: 'a,
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>
impl WasmList<i64>
pub fn as_le_slice<'a, T>(
&self,
store: impl Into<StoreContext<'a, T>>,
) -> &'a [i64]where
T: 'a,
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>
impl WasmList<u8>
pub fn as_le_slice<'a, T>(
&self,
store: impl Into<StoreContext<'a, T>>,
) -> &'a [u8] ⓘwhere
T: 'a,
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>
impl WasmList<u16>
pub fn as_le_slice<'a, T>(
&self,
store: impl Into<StoreContext<'a, T>>,
) -> &'a [u16]where
T: 'a,
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>
impl WasmList<u32>
pub fn as_le_slice<'a, T>(
&self,
store: impl Into<StoreContext<'a, T>>,
) -> &'a [u32]where
T: 'a,
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>
impl WasmList<u64>
pub fn as_le_slice<'a, T>(
&self,
store: impl Into<StoreContext<'a, T>>,
) -> &'a [u64]where
T: 'a,
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> 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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