Trait sc_allocator::Memory
source · pub trait Memory {
// Required methods
fn with_access_mut<R>(&mut self, run: impl FnOnce(&mut [u8]) -> R) -> R;
fn with_access<R>(&self, run: impl FnOnce(&[u8]) -> R) -> R;
fn grow(&mut self, additional: u32) -> Result<(), ()>;
fn pages(&self) -> u32;
fn max_pages(&self) -> Option<u32>;
}Expand description
Grants access to the memory for the allocator.
Memory of wasm is allocated in pages. A page has a constant size of 64KiB. The maximum allowed memory size as defined in the wasm specification is 4GiB (65536 pages).
Required Methods§
sourcefn with_access_mut<R>(&mut self, run: impl FnOnce(&mut [u8]) -> R) -> R
fn with_access_mut<R>(&mut self, run: impl FnOnce(&mut [u8]) -> R) -> R
Run the given closure run and grant it write access to the raw memory.
sourcefn with_access<R>(&self, run: impl FnOnce(&[u8]) -> R) -> R
fn with_access<R>(&self, run: impl FnOnce(&[u8]) -> R) -> R
Run the given closure run and grant it read access to the raw memory.
sourcefn max_pages(&self) -> Option<u32>
fn max_pages(&self) -> Option<u32>
Returns the maximum number of pages this memory is allowed to allocate.
The returned number needs to be smaller or equal to 65536. The returned number needs to be
bigger or equal to Self::pages.
If None is returned, there is no maximum (besides the maximum defined in the wasm spec).
Object Safety§
This trait is not object safe.