pub trait EstimateSize {
// Required method
fn estimated_heap_size(&self) -> usize;
// Provided method
fn estimated_size(&self) -> usize
where Self: Sized { ... }
}
Expand description
The trait for estimating the actual memory usage of a struct.
Used for cache eviction now.
Required Methods§
sourcefn estimated_heap_size(&self) -> usize
fn estimated_heap_size(&self) -> usize
The estimated heap size of the current struct in bytes.
Provided Methods§
sourcefn estimated_size(&self) -> usizewhere
Self: Sized,
fn estimated_size(&self) -> usizewhere
Self: Sized,
The estimated total size of the current struct in bytes, including the estimated_heap_size
and the size of Self
.
Implementations on Foreign Types§
source§impl EstimateSize for Value
impl EstimateSize for Value
fn estimated_heap_size(&self) -> usize
source§impl EstimateSize for Box<str>
impl EstimateSize for Box<str>
fn estimated_heap_size(&self) -> usize
source§impl EstimateSize for String
impl EstimateSize for String
fn estimated_heap_size(&self) -> usize
source§impl EstimateSize for FixedBitSet
impl EstimateSize for FixedBitSet
fn estimated_heap_size(&self) -> usize
source§impl EstimateSize for Builder
impl EstimateSize for Builder
fn estimated_heap_size(&self) -> usize
source§impl EstimateSize for Bytes
impl EstimateSize for Bytes
SAFETY: Bytes
can store a pointer in some cases, that may cause the size
of a Bytes
be calculated more than one and when memory stats is larger than the real value.