pub struct MemoryType { /* private fields */ }
runtime
only.Expand description
A descriptor for a WebAssembly memory type.
Memories are described in units of pages (64KB) and represent contiguous chunks of addressable memory.
Implementations§
source§impl MemoryType
impl MemoryType
sourcepub fn new(minimum: u32, maximum: Option<u32>) -> MemoryType
pub fn new(minimum: u32, maximum: Option<u32>) -> MemoryType
Creates a new descriptor for a 32-bit WebAssembly memory given the specified limits of the memory.
The minimum
and maximum
values here are specified in units of
WebAssembly pages, which are 64KiB by default. Use
MemoryTypeBuilder
if you want a
non-default page size.
§Panics
Panics if the minimum is greater than the maximum or if the minimum or maximum number of pages can result in a byte size that is not addressable with a 32-bit integer.
sourcepub fn new64(minimum: u64, maximum: Option<u64>) -> MemoryType
pub fn new64(minimum: u64, maximum: Option<u64>) -> MemoryType
Creates a new descriptor for a 64-bit WebAssembly memory given the specified limits of the memory.
The minimum
and maximum
values here are specified in units of
WebAssembly pages, which are 64KiB by default. Use
MemoryTypeBuilder
if you want a
non-default page size.
Note that 64-bit memories are part of the memory64 proposal for WebAssembly which is not fully standardized yet.
§Panics
Panics if the minimum is greater than the maximum or if the minimum or maximum number of pages can result in a byte size that is not addressable with a 64-bit integer.
Creates a new descriptor for shared WebAssembly memory given the specified limits of the memory.
The minimum
and maximum
values here are specified in units of
WebAssembly pages, which are 64KiB by default. Use
MemoryTypeBuilder
if you want a
non-default page size.
Note that shared memories are part of the threads proposal for WebAssembly which is not fully standardized yet.
§Panics
Panics if the minimum is greater than the maximum or if the minimum or maximum number of pages can result in a byte size that is not addressable with a 32-bit integer.
sourcepub fn builder() -> MemoryTypeBuilder
pub fn builder() -> MemoryTypeBuilder
Creates a new MemoryTypeBuilder
to configure all the various knobs
of the final memory type being created.
This is a convenience function for MemoryTypeBuilder::new
.
sourcepub fn is_64(&self) -> bool
pub fn is_64(&self) -> bool
Returns whether this is a 64-bit memory or not.
Note that 64-bit memories are part of the memory64 proposal for WebAssembly which is not standardized yet.
Returns whether this is a shared memory or not.
Note that shared memories are part of the threads proposal for WebAssembly which is not standardized yet.
sourcepub fn minimum(&self) -> u64
pub fn minimum(&self) -> u64
Returns minimum number of WebAssembly pages this memory must have.
Note that the return value, while a u64
, will always fit into a u32
for 32-bit memories.
sourcepub fn maximum(&self) -> Option<u64>
pub fn maximum(&self) -> Option<u64>
Returns the optionally-specified maximum number of pages this memory can have.
If this returns None
then the memory is not limited in size.
Note that the return value, while a u64
, will always fit into a u32
for 32-bit memories.
sourcepub fn page_size_log2(&self) -> u8
pub fn page_size_log2(&self) -> u8
The log2 of this memory’s page size, in bytes.
Trait Implementations§
source§impl Clone for MemoryType
impl Clone for MemoryType
source§fn clone(&self) -> MemoryType
fn clone(&self) -> MemoryType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MemoryType
impl Debug for MemoryType
source§impl From<MemoryType> for ExternType
impl From<MemoryType> for ExternType
source§fn from(ty: MemoryType) -> ExternType
fn from(ty: MemoryType) -> ExternType
source§impl Hash for MemoryType
impl Hash for MemoryType
source§impl PartialEq for MemoryType
impl PartialEq for MemoryType
impl Eq for MemoryType
impl StructuralPartialEq for MemoryType
Auto Trait Implementations§
impl Freeze for MemoryType
impl RefUnwindSafe for MemoryType
impl Send for MemoryType
impl Sync for MemoryType
impl Unpin for MemoryType
impl UnwindSafe for MemoryType
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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.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