Struct extism_runtime::PluginMemory
source · pub struct PluginMemory {
pub store: Option<Store<Internal>>,
pub memory: Memory,
pub live_blocks: BTreeMap<usize, usize>,
pub free: Vec<MemoryBlock>,
pub position: usize,
pub manifest: Manifest,
}Expand description
Handles memory for plugins
Fields§
§store: Option<Store<Internal>>wasmtime Store
memory: MemoryWASM memory
live_blocks: BTreeMap<usize, usize>Tracks allocated blocks
free: Vec<MemoryBlock>Tracks free blocks
position: usizeTracks current offset in memory
manifest: ManifestExtism manifest
Implementations§
source§impl PluginMemory
impl PluginMemory
sourcepub fn new(store: Store<Internal>, memory: Memory, manifest: Manifest) -> Self
pub fn new(store: Store<Internal>, memory: Memory, manifest: Manifest) -> Self
Create memory for a plugin
pub fn store(&self) -> &Store<Internal>
pub fn store_mut(&mut self) -> &mut Store<Internal>
sourcepub fn reinstantiate(&mut self) -> Result<(), Error>
pub fn reinstantiate(&mut self) -> Result<(), Error>
Moves module to a new store
sourcepub fn write(
&mut self,
pos: impl ToMemoryBlock,
data: impl AsRef<[u8]>
) -> Result<(), Error>
pub fn write( &mut self, pos: impl ToMemoryBlock, data: impl AsRef<[u8]> ) -> Result<(), Error>
Write slice to memory
sourcepub fn read(
&self,
pos: impl ToMemoryBlock,
data: impl AsMut<[u8]>
) -> Result<(), Error>
pub fn read( &self, pos: impl ToMemoryBlock, data: impl AsMut<[u8]> ) -> Result<(), Error>
Read slice from memory
sourcepub fn alloc_bytes(
&mut self,
data: impl AsRef<[u8]>
) -> Result<MemoryBlock, Error>
pub fn alloc_bytes( &mut self, data: impl AsRef<[u8]> ) -> Result<MemoryBlock, Error>
Allocate and copy data into the wasm memory
sourcepub fn get(&self, handle: impl ToMemoryBlock) -> Result<&[u8], Error>
pub fn get(&self, handle: impl ToMemoryBlock) -> Result<&[u8], Error>
Get bytes occupied by the provided memory handle
sourcepub fn get_mut(
&mut self,
handle: impl ToMemoryBlock
) -> Result<&mut [u8], Error>
pub fn get_mut( &mut self, handle: impl ToMemoryBlock ) -> Result<&mut [u8], Error>
Get mutable bytes occupied by the provided memory handle
sourcepub fn get_str(&self, handle: impl ToMemoryBlock) -> Result<&str, Error>
pub fn get_str(&self, handle: impl ToMemoryBlock) -> Result<&str, Error>
Get str occupied by the provided memory handle
sourcepub fn get_mut_str(
&mut self,
handle: impl ToMemoryBlock
) -> Result<&mut str, Error>
pub fn get_mut_str( &mut self, handle: impl ToMemoryBlock ) -> Result<&mut str, Error>
Get mutable str occupied by the provided memory handle
sourcepub fn ptr(&self, handle: impl ToMemoryBlock) -> Result<*mut u8, Error>
pub fn ptr(&self, handle: impl ToMemoryBlock) -> Result<*mut u8, Error>
Pointer to the provided memory handle
sourcepub fn block_length(&self, offs: usize) -> Option<usize>
pub fn block_length(&self, offs: usize) -> Option<usize>
Get the length of the block starting at offs
sourcepub fn at_offset(&self, offset: usize) -> Option<MemoryBlock>
pub fn at_offset(&self, offset: usize) -> Option<MemoryBlock>
Get the block at the specified offset
Auto Trait Implementations§
impl !RefUnwindSafe for PluginMemory
impl !Send for PluginMemory
impl !Sync for PluginMemory
impl Unpin for PluginMemory
impl !UnwindSafe for PluginMemory
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
§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where T: AsFilelike,
Query the “status” flags for the
self file descriptor.