Struct wai_bindgen_wasmer::Le
source · #[repr(packed(1))]pub struct Le<T>(T);
Expand description
Helper type representing a 1-byte-aligned little-endian value in memory.
This type is used in slice types for Wasmer host bindings. Guest types are not guaranteed to be either aligned or in the native endianness. This type wraps these types and provides explicit getters/setters to interact with the underlying value in a safe host-agnostic manner.
Tuple Fields§
§0: T
Implementations§
source§impl<T> Le<T>where
T: Endian,
impl<T> Le<T>where
T: Endian,
sourcepub fn new(t: T) -> Le<T>
pub fn new(t: T) -> Le<T>
Creates a new Le<T>
value where the internals are stored in a way
that’s safe to copy into wasm linear memory.
sourcepub fn get(&self) -> T
pub fn get(&self) -> T
Reads the value stored in this Le<T>
.
This will perform a correct read even if the underlying memory is
unaligned, and it will also convert to the host’s endianness for the
right representation of T
.
sourcepub fn set(&mut self, val: T)
pub fn set(&mut self, val: T)
Writes the val
to this slot.
This will work correctly even if the underlying memory is unaligned and
it will also automatically convert the val
provided to an endianness
appropriate for WebAssembly (little-endian).
pub(crate) fn from_slice(bytes: &[u8]) -> &[Le<T>]
pub(crate) fn from_slice_mut(bytes: &mut [u8]) -> &mut [Le<T>]
Trait Implementations§
source§impl<T: Endian + Ord> Ord for Le<T>
impl<T: Endian + Ord> Ord for Le<T>
source§impl<T: Endian + PartialEq> PartialEq for Le<T>
impl<T: Endian + PartialEq> PartialEq for Le<T>
source§impl<T: Endian + PartialOrd> PartialOrd for Le<T>
impl<T: Endian + PartialOrd> PartialOrd for Le<T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl<T: AllBytesValid> AllBytesValid for Le<T>
impl<T: Copy> Copy for Le<T>
impl<T: Endian + Eq> Eq for Le<T>
Auto Trait Implementations§
impl<T> Freeze for Le<T>where
T: Freeze,
impl<T> RefUnwindSafe for Le<T>where
T: RefUnwindSafe,
impl<T> Send for Le<T>where
T: Send,
impl<T> Sync for Le<T>where
T: Sync,
impl<T> Unpin for Le<T>where
T: Unpin,
impl<T> UnwindSafe for Le<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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