pub trait DataSize {
const IS_DYNAMIC: bool;
const STATIC_HEAP_SIZE: usize;
// Required method
fn estimate_heap_size(&self) -> usize;
// Provided method
fn estimate_detailed_heap_size(&self) -> MemUsageNode { ... }
}
Expand description
Indicates that a type knows how to approximate its memory usage.
Required Associated Constants§
Sourceconst IS_DYNAMIC: bool
const IS_DYNAMIC: bool
If true
, the type has a heap size that can vary at runtime, depending on the actual value.
Sourceconst STATIC_HEAP_SIZE: usize
const STATIC_HEAP_SIZE: usize
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§
Sourcefn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
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§
Sourcefn estimate_detailed_heap_size(&self) -> MemUsageNode
fn estimate_detailed_heap_size(&self) -> MemUsageNode
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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.