Struct wasmer::MemoryView

source ·
pub struct MemoryView<'a> { /* private fields */ }
Expand description

A WebAssembly memory view.

A memory view is used to read and write to the linear memory.

After a memory is grown a view must not be used anymore. Views are created using the Memory.grow() method.

Implementations§

Returns the size (in bytes) of the Memory.

Returns the size (in Pages) of the Memory.

Example
let m = Memory::new(&mut store, MemoryType::new(1, None, false)).unwrap();

assert_eq!(m.view(&mut store).size(), Pages(1));

Safely reads bytes from the memory at the given offset.

The full buffer will be filled, otherwise a MemoryAccessError is returned to indicate an out-of-bounds access.

This method is guaranteed to be safe (from the host side) in the face of concurrent writes.

Safely reads a single byte from memory at the given offset

This method is guaranteed to be safe (from the host side) in the face of concurrent writes.

Safely reads bytes from the memory at the given offset.

This method is similar to read but allows reading into an uninitialized buffer. An initialized view of the buffer is returned.

The full buffer will be filled, otherwise a MemoryAccessError is returned to indicate an out-of-bounds access.

This method is guaranteed to be safe (from the host side) in the face of concurrent writes.

Safely writes bytes to the memory at the given offset.

If the write exceeds the bounds of the memory then a MemoryAccessError is returned.

This method is guaranteed to be safe (from the host side) in the face of concurrent reads/writes.

Safely reads a single byte from memory at the given offset

This method is guaranteed to be safe (from the host side) in the face of concurrent writes.

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
The archived version of the pointer metadata for this type.
Converts some archived metadata to the pointer metadata for itself.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Deserializes using the given deserializer

Returns the argument unchanged.

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

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type for metadata in pointers and references to Self.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more