Trait ByteSize

Source
pub trait ByteSize {
    // Required method
    fn byte_size(&self) -> usize;
}
Expand description

An item having a ByteSize implementation specifies it has a known size, independent of if it’s Sized or not. The size reported by ByteSize may sometimes not be the same as std::mem::size_of, as alignment should not be taken into account for ByteSize. The size returned should not be taken as an exact value, though it should always match the final size. Assume this to be a good estimate instead.

Required Methods§

Source

fn byte_size(&self) -> usize

Given the current element, provide the amounts of bytes necessary to represent this element. This should never error and instead return size of 0.

Implementations on Foreign Types§

Source§

impl ByteSize for bool

Source§

impl ByteSize for f32

Source§

impl ByteSize for f64

Source§

impl ByteSize for i16

Source§

impl ByteSize for i32

Source§

impl ByteSize for i64

Source§

impl ByteSize for u8

Source§

impl ByteSize for u16

Source§

impl ByteSize for u32

Source§

impl ByteSize for u64

Source§

impl<T: TimeZone> ByteSize for DateTime<T>

Implementors§