pub trait RuntimeLinearMemory: Send + Sync {
fn byte_size(&self) -> usize;
fn maximum_byte_size(&self) -> Option<usize>;
fn grow_to(&mut self, size: usize) -> Result<()>;
fn vmmemory(&mut self) -> VMMemoryDefinition;
fn needs_init(&self) -> bool;
fn as_any_mut(&mut self) -> &mut dyn Any;
}
Expand description
A linear memory
Required Methods§
sourcefn maximum_byte_size(&self) -> Option<usize>
fn maximum_byte_size(&self) -> Option<usize>
Returns the maximum number of bytes the memory can grow to.
Returns None
if the memory is unbounded.
sourcefn grow_to(&mut self, size: usize) -> Result<()>
fn grow_to(&mut self, size: usize) -> Result<()>
Grow memory to the specified amount of bytes.
Returns an error if memory can’t be grown by the specified amount of bytes.
sourcefn vmmemory(&mut self) -> VMMemoryDefinition
fn vmmemory(&mut self) -> VMMemoryDefinition
Return a VMMemoryDefinition
for exposing the memory to compiled wasm
code.
sourcefn needs_init(&self) -> bool
fn needs_init(&self) -> bool
Does this memory need initialization? It may not if it already
has initial contents courtesy of the MemoryImage
passed to
RuntimeMemoryCreator::new_memory()
.
sourcefn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
For the pooling allocator, we must be able to downcast this trait to its underlying structure.