Trait kwap_msg::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 u8s, 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_msg::GetSize;

assert_eq!(vec![1u8, 2].get_size(), 2)

Get the max size that this data structure can acommodate.

By default, this returns None and can be left unimplemented for dynamic collections.

However, for fixed-size collections this method must be implemented.

Provided methods

Check if the runtime size is zero

use kwap_msg::GetSize;

assert!(Vec::<u8>::new().size_is_zero())

Is there no room left in this collection?

Implementations on Foreign Types

Implementors