Trait dyn_size_of::GetSize
source · pub trait GetSize {
const USES_DYN_MEM: bool = false;
fn size_bytes_dyn(&self) -> usize { ... }
fn size_bytes_content_dyn(&self) -> usize { ... }
fn size_bytes(&self) -> usize { ... }
}
Expand description
Provides methods to get dynamic and total size of the variable.
Provided Associated Constants§
sourceconst USES_DYN_MEM: bool = false
const USES_DYN_MEM: bool = false
true
if and only if the variables of this type can use dynamic (heap) memory.
Provided Methods§
sourcefn size_bytes_dyn(&self) -> usize
fn size_bytes_dyn(&self) -> usize
Returns approximate number of bytes occupied by dynamic (heap) part of self
.
Same as self.size_bytes() - std::mem::size_of_val(self)
.
sourcefn size_bytes_content_dyn(&self) -> usize
fn size_bytes_content_dyn(&self) -> usize
Returns approximate number of bytes occupied by dynamic (heap) part of self
content.
It usually equals to size_bytes_dyn()
.
However, sometimes it is smaller by the amount of memory reserved but not yet used
(e.g., size_bytes_content_dyn()
only takes into account the length of the vector and not its capacity).
sourcefn size_bytes(&self) -> usize
fn size_bytes(&self) -> usize
Returns approximate, total (including heap memory) number of bytes occupied by self
.