logo
pub trait DataSize {
    const IS_DYNAMIC: bool;
    const STATIC_HEAP_SIZE: usize;

    fn estimate_heap_size(&self) -> usize;

    fn estimate_detailed_heap_size(&self) -> MemUsageNode { ... }
}
Expand description

Indicates that a type knows how to approximate its memory usage.

Required Associated Constants

If true, the type has a heap size that can vary at runtime, depending on the actual value.

The amount of space a value of the type always occupies. If IS_DYNAMIC is false, this is the total amount of heap memory occupied by the value. Otherwise this is a lower bound.

Required Methods

Estimates the size of heap memory taken up by this value.

Does not include data on the stack, which is usually determined using mem::size_of.

Provided Methods

Create a tree of memory estimations.

Similar to estimate_heap_size, but the returned value is a tree that typically reports memory used by structs individually.

Requires the detailed feature to be enabled.

Implementations on Foreign Types

Implementors