Skip to main content

Sinks

Struct Sinks 

Source
pub struct Sinks { /* private fields */ }
Expand description

Callbacks used by CountingAlloc.

Fields are private so safe code cannot construct a sink that violates the global allocator contract. Use Self::noop or the unsafe Self::new constructor.

Implementations§

Source§

impl Sinks

Source

pub const fn noop() -> Self

Construct callbacks that discard every event.

Source

pub const unsafe fn new(alloc: fn(u64), realloc: fn(u64), dealloc: fn()) -> Self

Construct a certified sink set.

§Safety

Every callback must remain valid for the program’s lifetime and must never unwind, allocate, deallocate, acquire a lock, or otherwise re-enter the global allocator. It must also remain callable during thread-local destruction. All arithmetic in a callback must be non-panicking in every build profile.

fn allocation(_size: u64) {}
fn reallocation(_growth: u64) {}
fn deallocation() {}

// SAFETY: these empty callbacks cannot unwind, allocate, lock, or re-enter.
let sinks = unsafe {
    fdu_core::counters::alloc::Sinks::new(allocation, reallocation, deallocation)
};
let _allocator =
    fdu_core::counters::alloc::CountingAlloc::system(sinks);

Trait Implementations§

Source§

impl Clone for Sinks

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Sinks

Auto Trait Implementations§

§

impl Freeze for Sinks

§

impl RefUnwindSafe for Sinks

§

impl Send for Sinks

§

impl Sync for Sinks

§

impl Unpin for Sinks

§

impl UnsafeUnpin for Sinks

§

impl UnwindSafe for Sinks

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.