pub trait GetSize: Sized {
// Provided methods
fn get_stack_size() -> usize { ... }
fn get_heap_size(&self) -> usize { ... }
fn get_heap_size_with_tracker<T: GetSizeTracker>(
&self,
tracker: T,
) -> (usize, T) { ... }
fn get_size(&self) -> usize { ... }
fn get_size_with_tracker<T: GetSizeTracker>(&self, tracker: T) -> (usize, T) { ... }
}
Expand description
Determine the size in bytes an object occupies inside RAM.
Provided Methods§
Sourcefn get_stack_size() -> usize
fn get_stack_size() -> usize
Determines how may bytes this object occupies inside the stack.
The default implementation uses std::mem::size_of
and should work for almost all types.
Sourcefn get_heap_size(&self) -> usize
fn get_heap_size(&self) -> usize
Determines how many bytes this object occupies inside the heap.
The default implementation returns 0, assuming the object is fully allocated on the stack. It must be adjusted as appropriate for objects which hold data inside the heap.
Sourcefn get_heap_size_with_tracker<T: GetSizeTracker>(
&self,
tracker: T,
) -> (usize, T)
fn get_heap_size_with_tracker<T: GetSizeTracker>( &self, tracker: T, ) -> (usize, T)
Determines how many bytes this object occupies inside the heap while using a tracker
.
The default implementation ignores the tracker and calls get_heap_size
instead, returning the tracker untouched in the second argument.
Sourcefn get_size(&self) -> usize
fn get_size(&self) -> usize
Determines the total size of the object.
The default implementation simply adds up the results of get_stack_size
and get_heap_size
and is not meant to be changed.
Sourcefn get_size_with_tracker<T: GetSizeTracker>(&self, tracker: T) -> (usize, T)
fn get_size_with_tracker<T: GetSizeTracker>(&self, tracker: T) -> (usize, T)
Determines the total size of the object while using a tracker
.
The default implementation simply adds up the results of get_stack_size
and get_heap_size_with_tracker
and is not meant to
be changed.
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.