[][src]Struct context_allocator::allocators::BumpAllocator

pub struct BumpAllocator<MS: MemorySource> { /* fields omitted */ }

This is a very simple bump allocator of minimal utility.

It:-

  • Can efficiently shrink and grow (reallocate) for the most recent allocation made (useful when pushing to a RawVec, say).
  • Has no wrapping around at the end (but this could be achieved using a mirror ring buffer).
  • Has no ability to resize in place if dead space occurs before next allocation because of alignment.

Is suitable for use with short-lived coroutines, such as those used to make a DNS query.

This allocator NEVER grows or shrinks its memory region.

This allocator is not thread-safe.

Methods

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

pub fn new(
    memory_source: MS,
    memory_source_size: NonZeroUsize
) -> Result<Self, AllocErr>
[src]

New instance wrapping a block of memory.

Trait Implementations

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

fn contains(&self, from_memory_address: MemoryAddress) -> bool[src]

Returns true if this allocator is responsible for an allocation starting with the given from_memory_address. Read more

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

const ZeroSizedAllocation: MemoryAddress[src]

The sentinel value used for a zero-sized allocation.

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

Adapts to a GlobalAlloc and Alloc.

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

Adapts a reference to a GlobalAlloc and Alloc reference.

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

impl<MS: Debug + MemorySource> Debug for BumpAllocator<MS>[src]

Auto Trait Implementations

impl<MS> !Send for BumpAllocator<MS>

impl<MS> !Sync for BumpAllocator<MS>

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.