Struct wasmer_wasix::state::handles::thread_local::WasiInstanceGuardMemory
source · pub(crate) struct WasiInstanceGuardMemory<'a> {
borrow: &'a Memory,
_guard: WasiInstanceGuard<'a>,
}
Expand description
This provides access to the memory inside the instance
Fields§
§borrow: &'a Memory
§_guard: WasiInstanceGuard<'a>
Methods from Deref<Target = Memory>§
pub fn ty(&self, store: &impl AsStoreRef) -> MemoryType
pub fn ty(&self, store: &impl AsStoreRef) -> MemoryType
Returns the [MemoryType
] of the Memory
.
§Example
let mt = MemoryType::new(1, None, false);
let m = Memory::new(&mut store, mt).unwrap();
assert_eq!(m.ty(&mut store), mt);
pub fn view<'a>(&self, store: &'a (impl AsStoreRef + ?Sized)) -> MemoryView<'a>
pub fn view<'a>(&self, store: &'a (impl AsStoreRef + ?Sized)) -> MemoryView<'a>
Creates a view into the memory that then allows for read and write
pub fn grow<IntoPages>(
&self,
store: &mut impl AsStoreMut,
delta: IntoPages,
) -> Result<Pages, MemoryError>
pub fn grow<IntoPages>( &self, store: &mut impl AsStoreMut, delta: IntoPages, ) -> Result<Pages, MemoryError>
Grow memory by the specified amount of WebAssembly Pages
and return
the previous memory size.
§Example
let m = Memory::new(&mut store, MemoryType::new(1, Some(3), false)).unwrap();
let p = m.grow(&mut store, 2).unwrap();
assert_eq!(p, Pages(1));
assert_eq!(m.view(&mut store).size(), Pages(3));
§Errors
Returns an error if memory can’t be grown by the specified amount of pages.
let m = Memory::new(&mut store, MemoryType::new(1, Some(1), false)).unwrap();
// This results in an error: `MemoryError::CouldNotGrow`.
let s = m.grow(&mut store, 1).unwrap();
pub fn grow_at_least(
&self,
store: &mut impl AsStoreMut,
min_size: u64,
) -> Result<(), MemoryError>
pub fn grow_at_least( &self, store: &mut impl AsStoreMut, 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
pub fn reset(&self, store: &mut impl AsStoreMut) -> Result<(), MemoryError>
pub fn reset(&self, store: &mut impl AsStoreMut) -> Result<(), MemoryError>
Resets the memory back to zero length
pub fn copy_to_store(
&self,
store: &impl AsStoreRef,
new_store: &mut impl AsStoreMut,
) -> Result<Memory, MemoryError>
pub fn copy_to_store( &self, store: &impl AsStoreRef, new_store: &mut impl AsStoreMut, ) -> Result<Memory, MemoryError>
Attempts to duplicate this memory (if its clonable) in a new store (copied memory)
pub fn is_from_store(&self, store: &impl AsStoreRef) -> bool
pub fn is_from_store(&self, store: &impl AsStoreRef) -> bool
Checks whether this Memory
can be used with the given context.
pub fn try_clone(
&self,
store: &impl AsStoreRef,
) -> Result<VMMemory, MemoryError>
pub fn try_clone( &self, store: &impl AsStoreRef, ) -> Result<VMMemory, MemoryError>
Attempts to clone this memory (if its clonable)
Attempts to clone this memory (if its clonable) in a new store (cloned memory will be shared between those that clone it)
Get a [SharedMemory
].
Only returns Some(_)
if the memory is shared, and if the target
backend supports shared memory operations.
See [SharedMemory
] and its methods for more information.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for WasiInstanceGuardMemory<'a>
impl<'a> !RefUnwindSafe for WasiInstanceGuardMemory<'a>
impl<'a> !Send for WasiInstanceGuardMemory<'a>
impl<'a> !Sync for WasiInstanceGuardMemory<'a>
impl<'a> Unpin for WasiInstanceGuardMemory<'a>
impl<'a> !UnwindSafe for WasiInstanceGuardMemory<'a>
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more