Trait EstimateSize

Source
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§

Source

fn estimated_heap_size(&self) -> usize

The estimated heap size of the current struct in bytes.

Provided Methods§

Source

fn estimated_size(&self) -> usize
where 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

Source§

impl EstimateSize for Box<str>

Source§

impl EstimateSize for String

Source§

impl EstimateSize for FixedBitSet

Source§

impl EstimateSize for Builder

Source§

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.

Source§

impl EstimateSize for Value

Source§

impl<T1: EstimateSize, T2: EstimateSize> EstimateSize for (T1, T2)

Source§

impl<T: EstimateSize> EstimateSize for Option<T>

Source§

impl<T: EstimateSize> EstimateSize for Reverse<T>

Source§

impl<T: ZeroHeapSize> EstimateSize for Box<[T]>

Source§

impl<T: ZeroHeapSize> EstimateSize for Vec<T>

Source§

impl<T: ZeroHeapSize, const LEN: usize> EstimateSize for [T; LEN]

Implementors§