pub trait LinearMemory{
Show 13 methods
// Required methods
fn ty(&self) -> MemoryType;
fn size(&self) -> Pages;
fn style(&self) -> MemoryStyle;
fn grow(&mut self, delta: Pages) -> Result<Pages, MemoryError>;
fn vmmemory(&self) -> NonNull<VMMemoryDefinition>;
fn try_clone(
&self,
) -> Result<Box<dyn LinearMemory + Send + Sync + 'static>, MemoryError>;
fn copy(
&self,
) -> Result<Box<dyn LinearMemory + Send + Sync + 'static>, MemoryError>;
// Provided methods
fn grow_at_least(&mut self, _min_size: u64) -> Result<(), MemoryError> { ... }
fn reset(&mut self) -> Result<(), MemoryError> { ... }
fn as_shared(&self) -> Result<VMSharedMemory, MemoryError> { ... }
unsafe fn do_wait(
&mut self,
_dst: u32,
_expected: ExpectedValue,
_timeout: Option<Duration>,
) -> Result<u32, WaiterError> { ... }
fn do_notify(&mut self, _dst: u32, _count: u32) -> u32 { ... }
fn thread_conditions(&self) -> Option<&ThreadConditions> { ... }
}Expand description
Represents memory that is used by the WebAssembly module
Required Methods§
Sourcefn ty(&self) -> MemoryType
fn ty(&self) -> MemoryType
Returns the type for this memory.
Sourcefn style(&self) -> MemoryStyle
fn style(&self) -> MemoryStyle
Returns the memory style for this memory.
Sourcefn grow(&mut self, delta: Pages) -> Result<Pages, MemoryError>
fn grow(&mut self, delta: Pages) -> Result<Pages, MemoryError>
Grow memory by the specified amount of wasm pages.
Returns None if memory can’t be grown by the specified amount
of wasm pages.
Sourcefn vmmemory(&self) -> NonNull<VMMemoryDefinition>
fn vmmemory(&self) -> NonNull<VMMemoryDefinition>
Return a VMMemoryDefinition for exposing the memory to compiled wasm code.
Sourcefn try_clone(
&self,
) -> Result<Box<dyn LinearMemory + Send + Sync + 'static>, MemoryError>
fn try_clone( &self, ) -> Result<Box<dyn LinearMemory + Send + Sync + 'static>, MemoryError>
Attempts to clone this memory (if its cloneable)
Sourcefn copy(
&self,
) -> Result<Box<dyn LinearMemory + Send + Sync + 'static>, MemoryError>
fn copy( &self, ) -> Result<Box<dyn LinearMemory + Send + Sync + 'static>, MemoryError>
Copies this memory to a new memory
Provided Methods§
Sourcefn grow_at_least(&mut self, _min_size: u64) -> Result<(), MemoryError>
fn grow_at_least(&mut self, _min_size: u64) -> Result<(), MemoryError>
Grows the memory to at least a minimum size. If the memory is already big enough for the min size then this function does nothing
Sourcefn reset(&mut self) -> Result<(), MemoryError>
fn reset(&mut self) -> Result<(), MemoryError>
Resets the memory back to zero length
Returns a concrete shared memory handle if this memory is shared.
Sourceunsafe fn do_wait(
&mut self,
_dst: u32,
_expected: ExpectedValue,
_timeout: Option<Duration>,
) -> Result<u32, WaiterError>
unsafe fn do_wait( &mut self, _dst: u32, _expected: ExpectedValue, _timeout: Option<Duration>, ) -> Result<u32, WaiterError>
Add current thread to the waiter hash, and wait until notified or timeout. Return 0 if the waiter has been notified, 1 if there was a value mismatch, or 2 if the timeout occurred.
§Safety
the destination address must be a valid offset within this memory. It must also
be properly aligned for the expected value type; either 4-byte aligned for
ExpectedValue::U32 or 8-byte aligned for ExpectedValue::u64.
Sourcefn do_notify(&mut self, _dst: u32, _count: u32) -> u32
fn do_notify(&mut self, _dst: u32, _count: u32) -> u32
Notify waiters from the wait list. Return the number of waiters notified
Sourcefn thread_conditions(&self) -> Option<&ThreadConditions>
fn thread_conditions(&self) -> Option<&ThreadConditions>
Access the internal atomics handler.
Will be None if the memory does not support atomics.
Trait Implementations§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".