pub struct MemoryTypeBuilder { /* private fields */ }Expand description
A MemoryType builder.
Implementations§
Source§impl MemoryTypeBuilder
impl MemoryTypeBuilder
Sourcepub fn new() -> Self
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.
Sourcepub fn memory64(&mut self, memory64: bool) -> &mut Self
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.
Sourcepub fn min(&mut self, minimum: u64) -> &mut Self
pub fn min(&mut self, minimum: u64) -> &mut Self
Sets the minimum number of pages the built MemoryType supports.
The default minimum is 0.
Sourcepub fn max(&mut self, maximum: Option<u64>) -> &mut Self
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.
Sourcepub fn page_size_log2(&mut self, page_size_log2: u8) -> &mut Self
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.
Sourcepub fn build(self) -> Result<MemoryType, MemoryError>
pub fn build(self) -> Result<MemoryType, MemoryError>
Finalize the construction of the MemoryType.
§Errors
If the chosen configuration for the constructed MemoryType is invalid.