Trait PackedSize

Source
pub trait PackedSize {
    // Required method
    fn packed_size() -> usize;
}

Required Methods§

Source

fn packed_size() -> usize

Returns the packed size of the struct.

What is th packed size? Normally, struct members are aligned in a way that optimizes access speed. For example, on a 64bit platform, all members are aligned to start on a 64bit boundary https://doc.rust-lang.org/reference/type-layout.html.

Packed means what would be the size if no alignment would be used. In fact, packed size equals the sum of sizes of all members.

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.

Implementations on Foreign Types§

Source§

impl PackedSize for i8

Source§

impl PackedSize for i16

Source§

impl PackedSize for i32

Source§

impl PackedSize for i64

Source§

impl PackedSize for i128

Source§

impl PackedSize for u8

Source§

impl PackedSize for u16

Source§

impl PackedSize for u32

Source§

impl PackedSize for u64

Source§

impl PackedSize for u128

Implementors§