[][src]Trait alloc_compose::AllocAll

pub unsafe trait AllocAll {
    fn alloc_all(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr>;
fn alloc_all_zeroed(
        &mut self,
        layout: Layout
    ) -> Result<NonNull<[u8]>, AllocErr>;
fn dealloc_all(&mut self);
fn capacity(&self) -> usize;
fn capacity_left(&self) -> usize; fn is_empty(&self) -> bool { ... }
fn is_full(&self) -> bool { ... } }

Required methods

fn alloc_all(&mut self, layout: Layout) -> Result<NonNull<[u8]>, AllocErr>

Attempts to allocate all of the memory the allocator can provide.

If the allocator is currently not managing any memory, then it returns all the memory available to the allocator. Subsequent calls should not suceed.

On success, returns a [NonNull<[u8]>] meeting the size and alignment guarantees of layout.

The returned block may have a larger size than specified by layout.size(), and may or may not have its contents initialized.

[NonNull<[u8]>]: NonNull

Errors

Returning Err indicates that either memory is exhausted or layout does not meet allocator's size or alignment constraints.

Implementations are encouraged to return Err on memory exhaustion rather than panicking or aborting, but this is not a strict requirement. (Specifically: it is legal to implement this trait atop an underlying native allocation library that aborts on memory exhaustion.)

Clients wishing to abort computation in response to an allocation error are encouraged to call the handle_alloc_error function, rather than directly invoking panic! or similar.

fn alloc_all_zeroed(
    &mut self,
    layout: Layout
) -> Result<NonNull<[u8]>, AllocErr>

Behaves like alloc_all, but also ensures that the returned memory is zero-initialized.

Errors

Returning Err indicates that either memory is exhausted or layout does not meet allocator's size or alignment constraints.

Implementations are encouraged to return Err on memory exhaustion rather than panicking or aborting, but this is not a strict requirement. (Specifically: it is legal to implement this trait atop an underlying native allocation library that aborts on memory exhaustion.)

Clients wishing to abort computation in response to an allocation error are encouraged to call the handle_alloc_error function, rather than directly invoking panic! or similar.

fn dealloc_all(&mut self)

Deallocates all the memory the allocator had allocated.

fn capacity(&self) -> usize

Returns the total capacity available in this allocator.

fn capacity_left(&self) -> usize

Returns the free capacity left for allocating.

Loading content...

Provided methods

fn is_empty(&self) -> bool

Returns if the allocator is currently not holding memory.

fn is_full(&self) -> bool

Returns if the allocator has no more capacity left.

Loading content...

Implementors

impl AllocAll for Null[src]

impl<'_> AllocAll for Region<'_>[src]

impl<A: AllocAll, C: CallbackRef> AllocAll for Proxy<A, C>[src]

impl<A: AllocAll, const SIZE: usize> AllocAll for Chunk<A, SIZE> where
    Self: SizeIsPowerOfTwo, 
[src]

impl<Alloc, Prefix, Suffix> AllocAll for Affix<Alloc, Prefix, Suffix> where
    Alloc: AllocAll
[src]

impl<Small, Large, const THRESHOLD: usize> AllocAll for Segregate<Small, Large, THRESHOLD> where
    Small: AllocAll,
    Large: AllocAll
[src]

fn dealloc_all(&mut self)[src]

Deallocates all the memory the allocator had allocated.

fn capacity(&self) -> usize[src]

Returns the total capacity available in this allocator.

fn capacity_left(&self) -> usize[src]

Returns the free capacity left for allocating.

Loading content...