pub struct MemoryType { /* private fields */ }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
Available on crate feature runtime only.
pub fn new(minimum: u32, maximum: Option<u32>) -> MemoryType
runtime only.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
Available on crate feature runtime only.
pub fn new64(minimum: u64, maximum: Option<u64>) -> MemoryType
runtime only.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.
Available on crate feature runtime only.
runtime only.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
Available on crate feature runtime only.
pub fn builder() -> MemoryTypeBuilder
runtime only.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
Available on crate feature runtime only.
pub fn is_64(&self) -> bool
runtime only.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.
Available on crate feature runtime only.
runtime only.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
Available on crate feature runtime only.
pub fn minimum(&self) -> u64
runtime only.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>
Available on crate feature runtime only.
pub fn maximum(&self) -> Option<u64>
runtime only.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(&self) -> u64
Available on crate feature runtime only.
pub fn page_size(&self) -> u64
runtime only.This memory’s page size, in bytes.
Sourcepub fn page_size_log2(&self) -> u8
Available on crate feature runtime only.
pub fn page_size_log2(&self) -> u8
runtime only.The log2 of this memory’s page size, in bytes.
Sourcepub fn default_value(&self, store: impl AsContextMut) -> Result<RuntimeMemory>
Available on crate feature runtime only.
pub fn default_value(&self, store: impl AsContextMut) -> Result<RuntimeMemory>
runtime only.Construct a new memory import initialized to this memory type’s default state
Returns a host Memory in the given store with the configured initial
page size and zeroed contents.
Trait Implementations§
Source§impl Clone for MemoryType
Available on crate feature runtime only.
impl Clone for MemoryType
runtime only.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
Available on crate feature runtime only.
impl Debug for MemoryType
runtime only.Source§impl From<MemoryType> for ExternType
Available on crate feature runtime only.
impl From<MemoryType> for ExternType
runtime only.Source§fn from(ty: MemoryType) -> ExternType
fn from(ty: MemoryType) -> ExternType
Source§impl Hash for MemoryType
Available on crate feature runtime only.
impl Hash for MemoryType
runtime only.Source§impl PartialEq for MemoryType
Available on crate feature runtime only.
impl PartialEq for MemoryType
runtime only.impl Eq for MemoryType
runtime only.impl StructuralPartialEq for MemoryType
runtime only.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.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