[−][src]Struct wasmer_runtime_core::memory::Memory
A shared or unshared wasm linear memory.
A Memory
represents the memory used by a wasm instance.
Methods
impl Memory
[src]
pub fn new(desc: MemoryDescriptor) -> Result<Self, CreationError>
[src]
Create a new Memory
from a MemoryDescriptor
Usage:
let descriptor = MemoryDescriptor { minimum: Pages(10), maximum: None, shared: false, }; let memory = Memory::new(descriptor)?;
pub fn descriptor(&self) -> MemoryDescriptor
[src]
Return the MemoryDescriptor
that this memory
was created with.
pub fn grow(&self, delta: Pages) -> Result<Pages, GrowError>
[src]
Grow this memory by the specified number of pages.
pub fn size(&self) -> Pages
[src]
The size, in wasm pages, of this memory.
pub fn view<T: ValueType>(&self) -> MemoryView<T>
[src]
Return a "view" of the currently accessible memory. By
default, the view is unsyncronized, using regular memory
accesses. You can force a memory view to use atomic accesses
by calling the atomically
method.
Notes:
This method is safe (as in, it won't cause the host to crash or have UB), but it doesn't obey rust's rules involving data races, especially concurrent ones. Therefore, if this memory is shared between multiple threads, a single memory location can be mutated concurrently without synchronization.
Usage:
// Without synchronization. let view: MemoryView<u8> = memory.view(); for byte in view[0x1000 .. 0x1010].iter().map(|cell| cell.get()) { println!("byte: {}", byte); } // With synchronization. let atomic_view = view.atomically(); for byte in atomic_view[0x1000 .. 0x1010].iter().map(|atom| atom.load(Ordering::SeqCst)) { println!("byte: {}", byte); }
pub fn shared(self) -> Option<SharedMemory>
[src]
Convert this memory to a shared memory if the shared flag is present in the description used to create it.
Trait Implementations
impl IsExport for Memory
[src]
impl Clone for Memory
[src]
fn clone(&self) -> Memory
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Memory
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.