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,
§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
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