pub struct WasmtimeGuestMemory<'a> { /* private fields */ }
Expand description

Lightweight wasmtime::Memory wrapper so we can implement the wiggle::GuestMemory trait on it.

Implementations§

source§

impl<'a> WasmtimeGuestMemory<'a>

source

pub fn new(mem: &'a mut [u8]) -> Self

source

pub fn shared(mem: &'a [UnsafeCell<u8>]) -> Self

Trait Implementations§

source§

impl GuestMemory for WasmtimeGuestMemory<'_>

source§

fn base(&self) -> &[UnsafeCell<u8>]

Returns the base allocation of this guest memory, located in host memory. Read more
source§

fn has_outstanding_borrows(&self) -> bool

Indicates whether any outstanding borrows are known to the GuestMemory. This function must be false in order for it to be safe to recursively call into a WebAssembly module, or to manipulate the WebAssembly memory by any other means.
source§

fn is_shared_borrowed(&self, r: Region) -> bool

Check if a region of linear memory has any shared borrows.
source§

fn is_mut_borrowed(&self, r: Region) -> bool

Check if a region of linear memory is exclusively borrowed. This is called during any GuestPtr::read or GuestPtr::write operation to ensure that wiggle is not reading or writing a region of memory which Rust believes it has exclusive access to.
source§

fn shared_borrow(&self, r: Region) -> Result<BorrowHandle, GuestError>

Shared borrow a region of linear memory. This is used when constructing a GuestSlice or GuestStr. Those types will give Rust & (shared reference) access to the region of linear memory.
source§

fn mut_borrow(&self, r: Region) -> Result<BorrowHandle, GuestError>

Exclusively borrow a region of linear memory. This is used when constructing a GuestSliceMut or GuestStrMut. Those types will give Rust &mut access to the region of linear memory, therefore, the GuestMemory impl must guarantee that at most one BorrowHandle is issued to a given region, GuestMemory::has_outstanding_borrows is true for the duration of the borrow, and that GuestMemory::is_mut_borrowed of any overlapping region is false for the duration of the borrow.
source§

fn shared_unborrow(&self, h: BorrowHandle)

Unborrow a previously borrowed shared region. As long as GuestSlice and GuestStr are implemented correctly, a shared BorrowHandle should only be unborrowed once.
source§

fn mut_unborrow(&self, h: BorrowHandle)

Unborrow a previously borrowed mutable region. As long as GuestSliceMut and GuestStrMut are implemented correctly, a mut BorrowHandle should only be unborrowed once.
source§

fn is_shared_memory(&self) -> bool

Check if the underlying memory is shared across multiple threads; e.g., with a WebAssembly shared memory.
source§

fn ptr<'a, T>(&'a self, offset: T::Pointer) -> GuestPtr<'a, T>where Self: Sized, T: ?Sized + Pointee,

Convenience method for creating a GuestPtr at a particular offset. Read more
source§

impl Send for WasmtimeGuestMemory<'_>

source§

impl Sync for WasmtimeGuestMemory<'_>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Pointee for T

§

type Pointer = u32

source§

fn debug( pointer: <T as Pointee>::Pointer, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more