Struct wasmedge_sdk::Memory
source · pub struct Memory { /* private fields */ }
Expand description
Defines a linear memory.
Implementations§
source§impl Memory
impl Memory
sourcepub fn new(ty: MemoryType) -> WasmEdgeResult<Self>
pub fn new(ty: MemoryType) -> WasmEdgeResult<Self>
Creates a new wasm memory instance with the given type.
Argument
ty
- The type of the memory instance to be created.
Error
- If fail to create the memory instance, then WasmEdgeError::Mem(MemError::Create) is returned.
sourcepub fn name(&self) -> Option<&str>
pub fn name(&self) -> Option<&str>
Returns the exported name of this memory.
Notice that this field is meaningful only if this memory is used as an exported instance.
sourcepub fn mod_name(&self) -> Option<&str>
pub fn mod_name(&self) -> Option<&str>
Returns the name of the module instance from which this memory exports.
Notice that this field is meaningful only if this memory is used as an exported instance.
sourcepub fn ty(&self) -> &MemoryType
pub fn ty(&self) -> &MemoryType
Returns a reference to the type of this memory.
sourcepub fn page(&self) -> u32
pub fn page(&self) -> u32
Returns the size, in WebAssembly pages (64 KiB of each page), of this wasm memory.
sourcepub fn size(&self) -> u64
pub fn size(&self) -> u64
Returns the byte length of this memory. The returned value will be a multiple of the wasm page size, 64k.
sourcepub fn read_string(&self, offset: u32, len: u32) -> WasmEdgeResult<String>
pub fn read_string(&self, offset: u32, len: u32) -> WasmEdgeResult<String>
sourcepub fn grow(&mut self, count: u32) -> WasmEdgeResult<()>
pub fn grow(&mut self, count: u32) -> WasmEdgeResult<()>
sourcepub fn data_pointer(&self, offset: u32, len: u32) -> WasmEdgeResult<*const u8>
pub fn data_pointer(&self, offset: u32, len: u32) -> WasmEdgeResult<*const u8>
sourcepub fn data_pointer_mut(
&mut self,
offset: u32,
len: u32
) -> WasmEdgeResult<*mut u8>
pub fn data_pointer_mut( &mut self, offset: u32, len: u32 ) -> WasmEdgeResult<*mut u8>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Memory
impl Send for Memory
impl Sync for Memory
impl Unpin for Memory
impl !UnwindSafe for Memory
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more