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,
alignment: u32,
) -> Result<GuestPointer, RuntimeError>
pub fn allocate( &mut self, size: u32, alignment: u32, ) -> Result<GuestPointer, RuntimeError>
Returns a newly allocated buffer of size
bytes in the guest module’s memory
aligned to the requested alignment
.
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> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
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<T> LayoutRaw for T
impl<T> LayoutRaw for T
source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Gets the layout of the type.
source§impl<T> MockResults for T
impl<T> MockResults for T
§type Results = T
type Results = T
The mock native type of the results for the
MockInstance
.source§impl<T> Pointable for T
impl<T> Pointable for T
source§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
.
source§impl<T> Upcastable for T
impl<T> Upcastable for T
source§fn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
upcast ref
source§fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
upcast mut ref