Struct gear_core::memory::AllocationsContext
source · pub struct AllocationsContext { /* private fields */ }Expand description
Pages allocations context for the running program.
Implementations§
source§impl AllocationsContext
impl AllocationsContext
sourcepub fn new(
allocations: BTreeSet<WasmPage>,
static_pages: WasmPage,
max_pages: WasmPage
) -> Self
pub fn new( allocations: BTreeSet<WasmPage>, static_pages: WasmPage, max_pages: WasmPage ) -> Self
New allocations context.
Provide currently running program_id, boxed memory abstraction
and allocation manager. Also configurable static_pages and max_pages
are set.
sourcepub fn is_init_page(&self, page: WasmPage) -> bool
pub fn is_init_page(&self, page: WasmPage) -> bool
Return true if the page is the initial page,
it means that the page was already in the storage.
sourcepub fn alloc<G: GrowHandler>(
&mut self,
pages: WasmPage,
mem: &mut impl Memory,
charge_gas_for_grow: impl FnOnce(WasmPage) -> Result<(), ChargeError>
) -> Result<WasmPage, AllocError>
pub fn alloc<G: GrowHandler>( &mut self, pages: WasmPage, mem: &mut impl Memory, charge_gas_for_grow: impl FnOnce(WasmPage) -> Result<(), ChargeError> ) -> Result<WasmPage, AllocError>
Allocates specified number of continuously going pages and returns zero-based number of the first one.
Trait Implementations§
Auto Trait Implementations§
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