MemoryTypeBuilder

Struct MemoryTypeBuilder 

Source
pub struct MemoryTypeBuilder { /* private fields */ }
Expand description

A MemoryType builder.

Implementations§

Source§

impl MemoryTypeBuilder

Source

pub fn new() -> Self

Create a new builder for a MemoryType` with the default settings:

  • The minimum memory size is 0 pages.
  • The maximum memory size is unspecified.
  • The page size is 64KiB.
Source

pub fn memory64(&mut self, memory64: bool) -> &mut Self

Set whether this is a 64-bit memory type or not.

By default a memory is a 32-bit, a.k.a. false.

64-bit memories are part of the Wasm memory64 proposal.

Source

pub fn min(&mut self, minimum: u64) -> &mut Self

Sets the minimum number of pages the built MemoryType supports.

The default minimum is 0.

Source

pub fn max(&mut self, maximum: Option<u64>) -> &mut Self

Sets the optional maximum number of pages the built MemoryType supports.

A value of None means that there is no maximum number of pages.

The default maximum is None.

Source

pub fn page_size_log2(&mut self, page_size_log2: u8) -> &mut Self

Sets the log2 page size in bytes, for the built MemoryType.

The default value is 16, which results in the default Wasm page size of 64KiB (aka 2^16 or 65536).

Currently, the only allowed values are 0 (page size of 1) or 16 (the default). Future Wasm proposal extensions might change this limitation.

Non-default page sizes are part of the custom-page-sizes proposal for WebAssembly which is not fully standardized yet.

Source

pub fn build(self) -> Result<MemoryType, MemoryError>

Finalize the construction of the MemoryType.

§Errors

If the chosen configuration for the constructed MemoryType is invalid.

Trait Implementations§

Source§

impl Default for MemoryTypeBuilder

Source§

fn default() -> MemoryTypeBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.