pub struct MemoryAllocations { /* private fields */ }Implementations§
Source§impl MemoryAllocations
impl MemoryAllocations
pub const fn create() -> Self
pub fn new() -> Self
pub fn is_empty(&self) -> bool
pub fn is_allocations_empty(&self) -> bool
pub fn total_free(&self) -> u64
pub fn total_allocated(&self) -> u64
Sourcepub fn deallocate(&mut self, memory_id: MemoryId) -> MemoryAllocationResult<()>
pub fn deallocate(&mut self, memory_id: MemoryId) -> MemoryAllocationResult<()>
[deallocate] releases the owned memory allocation as
free for re-use by another desiring party. This means
the giving memory location is forever free for usage.
Sourcepub fn get(
&self,
memory_id: MemoryId,
) -> MemoryAllocationResult<MemoryAllocation>
pub fn get( &self, memory_id: MemoryId, ) -> MemoryAllocationResult<MemoryAllocation>
[get] returns the related MemoryAllocation object that is related to a
giving MemoryId to be used.
Sourcepub fn allocate(
&mut self,
desired_capacity: u64,
) -> MemoryAllocationResult<MemoryId>
pub fn allocate( &mut self, desired_capacity: u64, ) -> MemoryAllocationResult<MemoryId>
[allocate] attempts to allocate a memory location with the
desired capacity returning the pointer and ownership via the
returned MemoryId.
The receiver of the MemoryId will forever own that allocation
until the Self::deallocate method is called to free the
allocation.
Source§impl MemoryAllocations
impl MemoryAllocations
Sourcepub fn batch_for(
&mut self,
text_capacity: u64,
operations_capacity: u64,
optimized: bool,
) -> MemoryAllocationResult<Instructions>
pub fn batch_for( &mut self, text_capacity: u64, operations_capacity: u64, optimized: bool, ) -> MemoryAllocationResult<Instructions>
[batch_for] creates a new memory slot for encoding a singular instruction
batch.
Sourcepub fn batch_from(
&self,
optimized: bool,
completed: CompletedInstructions,
) -> MemoryAllocationResult<Instructions>
pub fn batch_from( &self, optimized: bool, completed: CompletedInstructions, ) -> MemoryAllocationResult<Instructions>
[batch_from] allows you continue building new batch instructions
from an already completed instruction memory slot. This added when you
are sure you do not need any immediate execution of the previous instruction
and will use callbacks or other means of retrieving results async or at a future
time, allowing you to encode as much information as possible before deliverying
to the other side, but also be aware this also means any potential error on
the host side that is caused by a batch will affect finality of your whole
batch.
Sourcepub fn get_slot(
&self,
completed: CompletedInstructions,
) -> MemoryAllocationResult<MemorySlot>
pub fn get_slot( &self, completed: CompletedInstructions, ) -> MemoryAllocationResult<MemorySlot>
[get_memory] retrieve the underlying memory allocation from the CompletedInstructions which can
allow you to inspect or interact with its raw contents as a MemoryAllocation.