[][src]Trait alloc_compose::AllocateAll

pub unsafe trait AllocateAll {
    pub fn allocate_all(&self) -> Result<NonNull<[u8]>, AllocError>;
pub fn deallocate_all(&self);
pub fn capacity(&self) -> usize;
pub fn capacity_left(&self) -> usize; pub fn allocate_all_zeroed(&self) -> Result<NonNull<[u8]>, AllocError> { ... }
pub fn is_empty(&self) -> bool { ... }
pub fn is_full(&self) -> bool { ... } }

Extends AllocRef for allocating or deallocating all memory at once.

Required methods

pub fn allocate_all(&self) -> Result<NonNull<[u8]>, AllocError>[src]

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 are unlikely to succeed.

On success, returns [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.

Also see AllocRef::alloc

Errors

Returning Err indicates that either memory is exhausted or layout does not meet allocators 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.

pub fn deallocate_all(&self)[src]

Deallocates all the memory the allocator had allocated.

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

Returns the total capacity available in this allocator.

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

Returns the free capacity left for allocating.

Loading content...

Provided methods

pub fn allocate_all_zeroed(&self) -> Result<NonNull<[u8]>, AllocError>[src]

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

Also see AllocRef::alloc_zeroed

Errors

Returning Err indicates that either memory is exhausted or layout does not meet allocators 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.

pub fn is_empty(&self) -> bool[src]

Returns if the allocator is currently not holding memory.

pub fn is_full(&self) -> bool[src]

Returns if the allocator has no more capacity left.

Loading content...

Implementations on Foreign Types

impl<A: ?Sized> AllocateAll for Box<A> where
    A: AllocateAll
[src]

This is supported on crate feature alloc only.

impl<A: ?Sized> AllocateAll for Rc<A> where
    A: AllocateAll
[src]

This is supported on crate feature alloc only.

impl<A: ?Sized> AllocateAll for Arc<A> where
    A: AllocateAll
[src]

This is supported on crate feature alloc only.
Loading content...

Implementors

impl AllocateAll for RawIntrusiveRegion[src]

impl AllocateAll for RawRegion[src]

impl AllocateAll for RawSharedRegion[src]

impl AllocateAll for Null[src]

impl<'_> AllocateAll for IntrusiveRegion<'_>[src]

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

impl<'_> AllocateAll for SharedRegion<'_>[src]

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

impl<A: ?Sized, '_> AllocateAll for &'_ A where
    A: AllocateAll
[src]

Loading content...