Struct linera_witty::Memory
source · pub struct Memory<'runtime, Instance>where
Instance: CabiReallocAlias + CabiFreeAlias,{ /* private fields */ }
Expand description
A handle to interface with a guest Wasm module instance’s memory.
Implementations§
source§impl<Instance> Memory<'_, Instance>where
Instance: CabiReallocAlias + CabiFreeAlias,
<Instance::Runtime as Runtime>::Memory: RuntimeMemory<Instance>,
impl<Instance> Memory<'_, Instance>where
Instance: CabiReallocAlias + CabiFreeAlias,
<Instance::Runtime as Runtime>::Memory: RuntimeMemory<Instance>,
sourcepub fn read(
&self,
location: GuestPointer,
length: u32,
) -> Result<Cow<'_, [u8]>, RuntimeError>
pub fn read( &self, location: GuestPointer, length: u32, ) -> Result<Cow<'_, [u8]>, RuntimeError>
Reads length
bytes from location
.
The underlying runtime may return either a memory slice or an owned buffer.
sourcepub fn write(
&mut self,
location: GuestPointer,
bytes: &[u8],
) -> Result<(), RuntimeError>
pub fn write( &mut self, location: GuestPointer, bytes: &[u8], ) -> Result<(), RuntimeError>
Writes bytes
to location
.
sourcepub fn allocate(&mut self, size: u32) -> Result<GuestPointer, RuntimeError>
pub fn allocate(&mut self, size: u32) -> Result<GuestPointer, RuntimeError>
Returns a newly allocated buffer of size
bytes in the guest module’s memory.
Calls the guest module to allocate the memory, so the resulting allocation is managed by the guest.
sourcepub fn deallocate(
&mut self,
allocation: GuestPointer,
) -> Result<(), RuntimeError>
pub fn deallocate( &mut self, allocation: GuestPointer, ) -> Result<(), RuntimeError>
Deallocates the allocation
managed by the guest.
Auto Trait Implementations§
impl<'runtime, Instance> Freeze for Memory<'runtime, Instance>
impl<'runtime, Instance> RefUnwindSafe for Memory<'runtime, Instance>where
<<Instance as Instance>::Runtime as Runtime>::Memory: RefUnwindSafe,
Instance: RefUnwindSafe,
<Instance as InstanceWithFunction<HCons<i32, HCons<i32, HCons<i32, HCons<i32, HNil>>>>, HCons<i32, HNil>>>::Function: RefUnwindSafe,
<Instance as InstanceWithFunction<HCons<i32, HNil>, HNil>>::Function: RefUnwindSafe,
impl<'runtime, Instance> Send for Memory<'runtime, Instance>
impl<'runtime, Instance> Sync for Memory<'runtime, Instance>
impl<'runtime, Instance> Unpin for Memory<'runtime, Instance>
impl<'runtime, Instance> !UnwindSafe for Memory<'runtime, Instance>
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
source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
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>
Converts
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>
Converts
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 moresource§impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
impl<M, I> RuntimeMemory<&mut I> for Mwhere
M: RuntimeMemory<I>,
source§fn read<'instance>(
&self,
instance: &'instance &mut I,
location: GuestPointer,
length: u32,
) -> Result<Cow<'instance, [u8]>, RuntimeError>
fn read<'instance>( &self, instance: &'instance &mut I, location: GuestPointer, length: u32, ) -> Result<Cow<'instance, [u8]>, RuntimeError>
Reads length
bytes from memory from the provided location
.
source§fn write(
&mut self,
instance: &mut &mut I,
location: GuestPointer,
bytes: &[u8],
) -> Result<(), RuntimeError>
fn write( &mut self, instance: &mut &mut I, location: GuestPointer, bytes: &[u8], ) -> Result<(), RuntimeError>
Writes the bytes
to memory at the provided location
.