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 { ... }
fn is_pod() -> bool { ... }
}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).
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.
Implementations on Foreign Types§
Source§impl SizeBytes for String
impl SizeBytes for String
Source§fn heap_size_bytes(&self) -> u64
fn heap_size_bytes(&self) -> u64
Does not take capacity into account.
Source§impl SizeBytes for StructArray
impl SizeBytes for StructArray
fn heap_size_bytes(&self) -> u64
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, U, V, W> SizeBytes for (T, U, V, W)
impl<T, U, V, W> SizeBytes for (T, U, V, W)
Source§impl<T: SizeBytes + NativeType> SizeBytes for PrimitiveArray<T>
impl<T: SizeBytes + NativeType> SizeBytes for PrimitiveArray<T>
fn heap_size_bytes(&self) -> u64
Source§impl<T: SizeBytes + Offset> SizeBytes for ListArray<T>
impl<T: SizeBytes + Offset> SizeBytes for ListArray<T>
fn heap_size_bytes(&self) -> u64
Source§impl<T: SizeBytes> SizeBytes for VecDeque<T>
impl<T: SizeBytes> SizeBytes for VecDeque<T>
Source§fn heap_size_bytes(&self) -> u64
fn heap_size_bytes(&self) -> u64
Does not take capacity into account.
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 [T; N]
impl<T: SizeBytes, const N: usize> SizeBytes for [T; N]
fn heap_size_bytes(&self) -> u64
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.