pub trait SizeBytes {
// Required method
fn heap_size_bytes(&self) -> u64;
// Provided methods
fn total_size_bytes(&self) -> u64 { ... }
fn stack_size_bytes(&self) -> u64 { ... }
}Expand description
Approximations of stack and heap size for both internal and external types.
Motly used for statistics and triggering events such as garbage collection.
Required Methods§
sourcefn heap_size_bytes(&self) -> u64
fn heap_size_bytes(&self) -> u64
Returns the total size of self on the heap, in bytes.
Provided Methods§
sourcefn total_size_bytes(&self) -> u64
fn total_size_bytes(&self) -> u64
Returns the total size of self in bytes, accounting for both stack and heap space.
sourcefn stack_size_bytes(&self) -> u64
fn stack_size_bytes(&self) -> u64
Returns the total size of self on the stack, in bytes.
Defaults to std::mem::size_of_val(self).
Implementations on Foreign Types§
source§impl<K: SizeBytes, V: SizeBytes> SizeBytes for BTreeMap<K, V>
impl<K: SizeBytes, V: SizeBytes> SizeBytes for BTreeMap<K, V>
fn heap_size_bytes(&self) -> u64
source§impl<K: SizeBytes, V: SizeBytes, S> SizeBytes for HashMap<K, V, S>
impl<K: SizeBytes, V: SizeBytes, S> SizeBytes for HashMap<K, V, S>
fn heap_size_bytes(&self) -> u64
source§impl<T: SizeBytes> SizeBytes for Vec<T>
impl<T: SizeBytes> SizeBytes for Vec<T>
source§fn heap_size_bytes(&self) -> u64
fn heap_size_bytes(&self) -> u64
Does not take capacity into account.
source§impl<T: SizeBytes, const N: usize> SizeBytes for SmallVec<[T; N]>
impl<T: SizeBytes, const N: usize> SizeBytes for SmallVec<[T; N]>
source§fn heap_size_bytes(&self) -> u64
fn heap_size_bytes(&self) -> u64
Does not take capacity into account.