Skip to main content

RuntimeMemory

Struct RuntimeMemory 

Source
pub struct RuntimeMemory<M: Memory> { /* private fields */ }
Expand description

RuntimeMemory

Cloneable virtual memory opened through a runtime’s committed authority. Implements Memory for stable structures without exposing the backing memory or an alternate manager. Cloning does not require M: Clone. IO checks the virtual extent before upstream bucket translation. Empty IO is valid at the end of memory, but not beyond it. Reads preserve the upstream optimized support for uninitialized destinations through Memory::read_unsafe. Growth reserves physical capacity before assigning manager buckets. Ordinary backing refusal, arithmetic overflow and bucket exhaustion return typed errors without changing virtual extents or manager metadata. Backing implementations must obey the Memory contract; traps and partial writes are not transactions on native memory. Typed collections retain their own failure behavior.

Implementations§

Source§

impl<M: Memory> RuntimeMemory<M>

Source

pub fn grow(&self, pages: u64) -> Result<u64, RuntimeGrowError>

Grow by the requested pages, returning the previous virtual page count.

Capacity is reserved before assigning manager buckets. Ordinary refusal preserves virtual extents and manager metadata and permits retry. The upstream Memory::grow adapter translates errors into its required -1 sentinel; direct runtime callers receive super::RuntimeGrowError. A zero-page request returns the current extent without backing IO or manager mutation, after checking for reentrant growth.

§Panics

Panics if a private growth-accounting invariant is broken or backing memory panics.

Trait Implementations§

Source§

impl<M: Memory> Clone for RuntimeMemory<M>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<M: Memory> Memory for RuntimeMemory<M>

Source§

fn size(&self) -> u64

Returns the current size of the memory in WebAssembly pages. Read more
Source§

fn grow(&self, pages: u64) -> i64

Grows the memory by pages pages filled with zeroes. Read more
Source§

fn read(&self, offset: u64, dst: &mut [u8])

Copies dst.len() bytes from memory starting at offset into dst. Read more
Source§

unsafe fn read_unsafe(&self, offset: u64, dst: *mut u8, count: usize)

Unsafe variant of read for advanced use. Read more
Source§

fn write(&self, offset: u64, src: &[u8])

Copies src.len() bytes from src into memory starting at offset. Read more

Auto Trait Implementations§

§

impl<M> !Freeze for RuntimeMemory<M>

§

impl<M> !RefUnwindSafe for RuntimeMemory<M>

§

impl<M> !Send for RuntimeMemory<M>

§

impl<M> !Sync for RuntimeMemory<M>

§

impl<M> !UnwindSafe for RuntimeMemory<M>

§

impl<M> Unpin for RuntimeMemory<M>
where VirtualMemory<Rc<M>>: Unpin, Rc<GrowthState<M>>: Unpin,

§

impl<M> UnsafeUnpin for RuntimeMemory<M>
where VirtualMemory<Rc<M>>: UnsafeUnpin, Rc<GrowthState<M>>: UnsafeUnpin,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.