pub struct AllocationsContext { /* private fields */ }
Expand description
Pages allocations context for the running program.
Implementations§
Source§impl AllocationsContext
impl AllocationsContext
Sourcepub fn try_new(
memory_size: WasmPagesAmount,
allocations: IntervalsTree<WasmPage>,
static_pages: WasmPagesAmount,
stack_end: Option<WasmPage>,
max_pages: WasmPagesAmount,
) -> Result<Self, MemorySetupError>
pub fn try_new( memory_size: WasmPagesAmount, allocations: IntervalsTree<WasmPage>, static_pages: WasmPagesAmount, stack_end: Option<WasmPage>, max_pages: WasmPagesAmount, ) -> Result<Self, MemorySetupError>
New allocations context.
Provide currently running program_id
, boxed memory abstraction
and allocation manager. Also configurable static_pages
and max_pages
are set.
Returns MemorySetupError
on incorrect memory params.
Sourcepub fn alloc<Context, G: GrowHandler<Context>>(
&mut self,
ctx: &mut Context,
mem: &mut impl Memory<Context>,
pages: WasmPagesAmount,
charge_gas_for_grow: impl FnOnce(WasmPagesAmount) -> Result<(), ChargeError>,
) -> Result<WasmPage, AllocError>
pub fn alloc<Context, G: GrowHandler<Context>>( &mut self, ctx: &mut Context, mem: &mut impl Memory<Context>, pages: WasmPagesAmount, charge_gas_for_grow: impl FnOnce(WasmPagesAmount) -> Result<(), ChargeError>, ) -> Result<WasmPage, AllocError>
Allocates specified number of continuously going pages and returns zero-based number of the first one.
Sourcepub fn free_range(
&mut self,
interval: Interval<WasmPage>,
) -> Result<(), AllocError>
pub fn free_range( &mut self, interval: Interval<WasmPage>, ) -> Result<(), AllocError>
Try to free pages in range. Will only return error if range is invalid.
Currently running program should own this pages.
Sourcepub fn into_parts(
self,
) -> (WasmPagesAmount, IntervalsTree<WasmPage>, IntervalsTree<WasmPage>)
pub fn into_parts( self, ) -> (WasmPagesAmount, IntervalsTree<WasmPage>, IntervalsTree<WasmPage>)
Decomposes this instance and returns allocations.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AllocationsContext
impl RefUnwindSafe for AllocationsContext
impl Send for AllocationsContext
impl Sync for AllocationsContext
impl Unpin for AllocationsContext
impl UnwindSafe for AllocationsContext
Blanket Implementations§
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