[][src]Trait context_allocator::allocators::Allocator

pub trait Allocator: Debug + Sized {
    const ZeroSizedAllocation: MemoryAddress;

    fn allocate(
        &self,
        non_zero_size: NonZeroUsize,
        non_zero_power_of_two_alignment: NonZeroUsize
    ) -> Result<MemoryAddress, AllocErr>;
fn deallocate(
        &self,
        non_zero_size: NonZeroUsize,
        non_zero_power_of_two_alignment: NonZeroUsize,
        current_memory: MemoryAddress
    );
fn growing_reallocate(
        &self,
        non_zero_new_size: NonZeroUsize,
        non_zero_power_of_two_alignment: NonZeroUsize,
        non_zero_current_size: NonZeroUsize,
        current_memory: MemoryAddress
    ) -> Result<MemoryAddress, AllocErr>;
fn shrinking_reallocate(
        &self,
        non_zero_new_size: NonZeroUsize,
        non_zero_power_of_two_alignment: NonZeroUsize,
        non_zero_current_size: NonZeroUsize,
        current_memory: MemoryAddress
    ) -> Result<MemoryAddress, AllocErr>; fn adapt<'a>(&'a self) -> AllocatorAdaptor<'a, Self> { ... }
fn adapt_reference<'a>(&'a self) -> &'a AllocatorAdaptor<'a, Self> { ... } }

A helper trait that brings together the core, common functionality required to implement the traits GlobalAlloc and Alloc.

Associated Constants

const ZeroSizedAllocation: MemoryAddress

The sentinel value used for a zero-sized allocation.

Loading content...

Required methods

fn allocate(
    &self,
    non_zero_size: NonZeroUsize,
    non_zero_power_of_two_alignment: NonZeroUsize
) -> Result<MemoryAddress, AllocErr>

Allocate memory.

fn deallocate(
    &self,
    non_zero_size: NonZeroUsize,
    non_zero_power_of_two_alignment: NonZeroUsize,
    current_memory: MemoryAddress
)

Deallocate (free) memory.

The parameter memory will never be the value Self::ZeroSizedAllocation and will always have been allocated by this Allocator.

fn growing_reallocate(
    &self,
    non_zero_new_size: NonZeroUsize,
    non_zero_power_of_two_alignment: NonZeroUsize,
    non_zero_current_size: NonZeroUsize,
    current_memory: MemoryAddress
) -> Result<MemoryAddress, AllocErr>

Reallocate memory by growing it.

non_zero_new_size will always be greater than non_zero_current_size. non_zero_power_of_two_alignment will be the same value as passed to allocate().

fn shrinking_reallocate(
    &self,
    non_zero_new_size: NonZeroUsize,
    non_zero_power_of_two_alignment: NonZeroUsize,
    non_zero_current_size: NonZeroUsize,
    current_memory: MemoryAddress
) -> Result<MemoryAddress, AllocErr>

Reallocate memory by shrinking it.

non_zero_new_size will always be less than non_zero_current_size. non_zero_power_of_two_alignment will be the same value as passed to allocate().

Loading content...

Provided methods

fn adapt<'a>(&'a self) -> AllocatorAdaptor<'a, Self>

Adapts to a GlobalAlloc and Alloc.

fn adapt_reference<'a>(&'a self) -> &'a AllocatorAdaptor<'a, Self>

Adapts a reference to a GlobalAlloc and Alloc reference.

Loading content...

Implementors

impl Allocator for MemoryMapAllocator[src]

const ZeroSizedAllocation: MemoryAddress[src]

fn adapt<'a>(&'a self) -> AllocatorAdaptor<'a, Self>[src]

fn adapt_reference<'a>(&'a self) -> &'a AllocatorAdaptor<'a, Self>[src]

impl<'a, A: 'a + Allocator> Allocator for AllocatorAdaptor<'a, A>[src]

const ZeroSizedAllocation: MemoryAddress[src]

fn adapt<'a>(&'a self) -> AllocatorAdaptor<'a, Self>[src]

fn adapt_reference<'a>(&'a self) -> &'a AllocatorAdaptor<'a, Self>[src]

impl<A: Alloc> Allocator for AllocToAllocatorAdaptor<A>[src]

const ZeroSizedAllocation: MemoryAddress[src]

fn adapt<'a>(&'a self) -> AllocatorAdaptor<'a, Self>[src]

fn adapt_reference<'a>(&'a self) -> &'a AllocatorAdaptor<'a, Self>[src]

impl<GA: GlobalAlloc> Allocator for GlobalAllocToAllocatorAdaptor<GA>[src]

const ZeroSizedAllocation: MemoryAddress[src]

fn adapt<'a>(&'a self) -> AllocatorAdaptor<'a, Self>[src]

fn adapt_reference<'a>(&'a self) -> &'a AllocatorAdaptor<'a, Self>[src]

impl<MS: MemorySource> Allocator for ContextAllocator<MS>[src]

const ZeroSizedAllocation: MemoryAddress[src]

fn adapt<'a>(&'a self) -> AllocatorAdaptor<'a, Self>[src]

fn adapt_reference<'a>(&'a self) -> &'a AllocatorAdaptor<'a, Self>[src]

impl<MS: MemorySource> Allocator for BitSetAllocator<MS>[src]

const ZeroSizedAllocation: MemoryAddress[src]

fn adapt<'a>(&'a self) -> AllocatorAdaptor<'a, Self>[src]

fn adapt_reference<'a>(&'a self) -> &'a AllocatorAdaptor<'a, Self>[src]

impl<MS: MemorySource> Allocator for BumpAllocator<MS>[src]

const ZeroSizedAllocation: MemoryAddress[src]

fn adapt<'a>(&'a self) -> AllocatorAdaptor<'a, Self>[src]

fn adapt_reference<'a>(&'a self) -> &'a AllocatorAdaptor<'a, Self>[src]

impl<MS: MemorySource> Allocator for MultipleBinarySearchTreeAllocator<MS>[src]

const ZeroSizedAllocation: MemoryAddress[src]

fn adapt<'a>(&'a self) -> AllocatorAdaptor<'a, Self>[src]

fn adapt_reference<'a>(&'a self) -> &'a AllocatorAdaptor<'a, Self>[src]

Loading content...