pub trait GetSize {
const USES_DYN_MEM: bool = false;
// Provided methods
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.
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.