pub struct Allocator<'amx> { /* private fields */ }Expand description
AMX heap allocator with automatic release (RAII).
Captures the value of amx.hea at creation time and restores it on Drop,
freeing everything allocated by the Allocator in a single operation.
Do not use multiple nested Allocators — each one restores to a different
heap point.
Implementations§
Source§impl<'amx> Allocator<'amx>
impl<'amx> Allocator<'amx>
Sourcepub fn allot<T>(&self, init_value: T) -> Result<Ref<'_, T>, AmxError>where
T: AmxPrimitive,
pub fn allot<T>(&self, init_value: T) -> Result<Ref<'_, T>, AmxError>where
T: AmxPrimitive,
Allocates a single cell on the heap and initializes it with init_value.
§Errors
AmxError::Memory if the VM heap is exhausted.
Sourcepub fn allot_array<T>(&self, array: &[T]) -> Result<Buffer<'_>, AmxError>where
T: AmxCell<'amx> + AmxPrimitive,
pub fn allot_array<T>(&self, array: &[T]) -> Result<Buffer<'_>, AmxError>where
T: AmxCell<'amx> + AmxPrimitive,
Allocates space for array.len() cells and copies the content (AmxCell::as_cell).
§Errors
AmxError::Memory if the VM heap is exhausted.
Trait Implementations§
Auto Trait Implementations§
impl<'amx> !Send for Allocator<'amx>
impl<'amx> !Sync for Allocator<'amx>
impl<'amx> Freeze for Allocator<'amx>
impl<'amx> RefUnwindSafe for Allocator<'amx>
impl<'amx> Unpin for Allocator<'amx>
impl<'amx> UnsafeUnpin for Allocator<'amx>
impl<'amx> UnwindSafe for Allocator<'amx>
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