pub struct MallocSizeOfOps {
    pub(crate) size_of_op: unsafe extern "C" fn(ptr: *const c_void) -> usize,
    pub(crate) enclosing_size_of_op: Option<unsafe extern "C" fn(ptr: *const c_void) -> usize>,
    pub(crate) have_seen_ptr_op: Option<Box<dyn FnMut(*const c_void) -> bool>>,
}
Expand description

Operations used when measuring heap usage of data structures.

Fields

size_of_op: unsafe extern "C" fn(ptr: *const c_void) -> usize

A function that returns the size of a heap allocation.

enclosing_size_of_op: Option<unsafe extern "C" fn(ptr: *const c_void) -> usize>

Like size_of_op, but can take an interior pointer. Optional because not all allocators support this operation. If it’s not provided, some memory measurements will actually be computed estimates rather than real and accurate measurements.

have_seen_ptr_op: Option<Box<dyn FnMut(*const c_void) -> bool>>

Check if a pointer has been seen before, and remember it for next time. Useful when measuring Rcs and Arcs. Optional, because many places don’t need it.

Implementations

Check if an allocation is empty. This relies on knowledge of how Rust handles empty allocations, which may change in the future.

Call size_of_op on ptr, first checking that the allocation isn’t empty, because some types (such as Vec) utilize empty allocations.

Is an enclosing_size_of_op available?

Call enclosing_size_of_op, which must be available, on ptr, which must not be empty.

Call have_seen_ptr_op on ptr.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more