[−][src]Struct holochain_wasmer_host::prelude::memory::Memory
A shared or unshared wasm linear memory.
A Memory
represents the memory used by a wasm instance.
Implementations
impl Memory
[src]
pub fn new(desc: MemoryDescriptor) -> Result<Memory, CreationError>
[src]
Create a new Memory
from a MemoryDescriptor
Usage:
fn create_memory() -> Result<()> { let descriptor = MemoryDescriptor::new(Pages(10), None, false).unwrap(); let memory = Memory::new(descriptor)?; Ok(()) }
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>(&self) -> MemoryView<'_, T, NonAtomically> where
T: ValueType,
[src]
T: ValueType,
Return a "view" of the currently accessible memory. By
default, the view is unsynchronized, 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::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); }
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Memory
[src]
impl Send for Memory
[src]
impl Sync for Memory
[src]
impl Unpin for Memory
[src]
impl !UnwindSafe for Memory
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Pointable for T
pub const ALIGN: usize
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
pub unsafe fn drop(ptr: usize)
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,