[][src]Trait alloc_compose::CallbackRef

pub unsafe trait CallbackRef {
    fn before_alloc(&self, layout: Layout, init: AllocInit) { ... }
fn after_alloc(
        &self,
        layout: Layout,
        init: AllocInit,
        result: Result<MemoryBlock, AllocErr>
    ) { ... }
fn before_dealloc(&self, ptr: NonNull<u8>, layout: Layout) { ... }
fn after_dealloc(&self, ptr: NonNull<u8>, layout: Layout) { ... }
fn before_grow(
        &self,
        ptr: NonNull<u8>,
        layout: Layout,
        new_size: usize,
        placement: ReallocPlacement,
        init: AllocInit
    ) { ... }
fn after_grow(
        &self,
        ptr: NonNull<u8>,
        layout: Layout,
        new_size: usize,
        placement: ReallocPlacement,
        init: AllocInit,
        result: Result<MemoryBlock, AllocErr>
    ) { ... }
fn before_shrink(
        &self,
        ptr: NonNull<u8>,
        layout: Layout,
        new_size: usize,
        placement: ReallocPlacement
    ) { ... }
fn after_shrink(
        &self,
        ptr: NonNull<u8>,
        layout: Layout,
        new_size: usize,
        placement: ReallocPlacement,
        result: Result<MemoryBlock, AllocErr>
    ) { ... }
fn before_owns(&self) { ... }
fn after_owns(&self, success: bool) { ... }
fn by_ref(&self) -> &Self { ... } }

Backend for the Proxy allocator.

As Callback is used in Proxy and AllocRef requires, that a cloned allocator must behave like the same allocator, Clone must not be implemented on types, which don't have a shared state. It's possible to use a reference by calling by_ref or to wrapping them into Rc or Arc in order to make them cloneable instead. Note, that Box, Rc, and Arc requires the "alloc"-feature to be enabled.

Safety

  • Clone must not be implemented on types, which don't have a shared state.

Provided methods

fn before_alloc(&self, layout: Layout, init: AllocInit)

Called before alloc was invoked.

fn after_alloc(
    &self,
    layout: Layout,
    init: AllocInit,
    result: Result<MemoryBlock, AllocErr>
)

Called after alloc was invoked.

fn before_dealloc(&self, ptr: NonNull<u8>, layout: Layout)

Called before dealloc was invoked.

fn after_dealloc(&self, ptr: NonNull<u8>, layout: Layout)

Called after dealloc was invoked.

fn before_grow(
    &self,
    ptr: NonNull<u8>,
    layout: Layout,
    new_size: usize,
    placement: ReallocPlacement,
    init: AllocInit
)

Called before grow was invoked.

fn after_grow(
    &self,
    ptr: NonNull<u8>,
    layout: Layout,
    new_size: usize,
    placement: ReallocPlacement,
    init: AllocInit,
    result: Result<MemoryBlock, AllocErr>
)

Called after grow was invoked.

fn before_shrink(
    &self,
    ptr: NonNull<u8>,
    layout: Layout,
    new_size: usize,
    placement: ReallocPlacement
)

Called before shrink was invoked.

fn after_shrink(
    &self,
    ptr: NonNull<u8>,
    layout: Layout,
    new_size: usize,
    placement: ReallocPlacement,
    result: Result<MemoryBlock, AllocErr>
)

Called after shrink was invoked.

fn before_owns(&self)

Called before owns was invoked.

fn after_owns(&self, success: bool)

Called after owns was invoked.

fn by_ref(&self) -> &Self

Creates a "by reference" adaptor for this instance of CallbackRef.

The returned adaptor also implements CallbackRef and will simply borrow this.

Loading content...

Implementations on Foreign Types

impl<C: CallbackRef> CallbackRef for Box<C>[src]

This is only available with the "alloc"-feature enabled.

impl<C: CallbackRef> CallbackRef for Rc<C>[src]

This is only available with the "alloc"-feature enabled.

impl<C: CallbackRef> CallbackRef for Arc<C>[src]

This is only available with the "alloc"-feature enabled.

Loading content...

Implementors

impl CallbackRef for AtomicCounter[src]

impl CallbackRef for Counter[src]

impl CallbackRef for FilteredAtomicCounter[src]

impl CallbackRef for FilteredCounter[src]

impl<C: CallbackRef, '_> CallbackRef for &'_ C[src]

Loading content...