Trait kwap_common::GetSize [−][src]
pub trait GetSize {
fn get_size(&self) -> usize;
fn max_size(&self) -> Option<usize>;
fn size_is_zero(&self) -> bool { ... }
fn is_full(&self) -> bool { ... }
}
Expand description
Get the runtime size (in bytes) of a struct
Note
For collections this just yields the number of elements (Vec::len
, tinyvec::ArrayVec::len
),
and when the collection is over u8
s,
then get_size
represents the number of bytes in the collection.
Required methods
Get the runtime size (in bytes) of a struct
For collections this is always equivalent to calling an inherent len
method.
use kwap_common::GetSize;
assert_eq!(vec![1u8, 2].get_size(), 2)
Provided methods
fn size_is_zero(&self) -> bool
fn size_is_zero(&self) -> bool
Check if the runtime size is zero
use kwap_common::GetSize;
assert!(Vec::<u8>::new().size_is_zero())