Skip to main content

PackedElement

Trait PackedElement 

Source
pub unsafe trait PackedElement: Element<Spans = PackedSpans<Self>> + Copy {
    // Required method
    fn validate_all(bytes: &[u8]) -> bool;
}
Expand description

An element whose values are packed as their octets, one after the other, which is what allows a Buf of them to be seen as a slice, see Buf::as_slice, and written, see BufMut.

§Safety

The type must have no padding and not be zero-sized, its values must be exactly the octets Self::validate_all accepts, read as they are, and octets that are all zeroes must be a valid value, which is what new room in a storage holds.

Required Methods§

Source

fn validate_all(bytes: &[u8]) -> bool

Whether the octets of a whole number of consecutive values are all valid values, in a single pass: what octets are checked with when they are cast, and what Element::validate is for one value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl PackedElement for bool

Source§

fn validate_all(_bytes: &[u8]) -> bool

Source§

impl PackedElement for f32

Source§

fn validate_all(_bytes: &[u8]) -> bool

Source§

impl PackedElement for f64

Source§

fn validate_all(_bytes: &[u8]) -> bool

Source§

impl PackedElement for i8

Source§

fn validate_all(_bytes: &[u8]) -> bool

Source§

impl PackedElement for i16

Source§

fn validate_all(_bytes: &[u8]) -> bool

Source§

impl PackedElement for i32

Source§

fn validate_all(_bytes: &[u8]) -> bool

Source§

impl PackedElement for i64

Source§

fn validate_all(_bytes: &[u8]) -> bool

Source§

impl PackedElement for u8

Source§

fn validate_all(_bytes: &[u8]) -> bool

Source§

impl PackedElement for u16

Source§

fn validate_all(_bytes: &[u8]) -> bool

Source§

impl PackedElement for u32

Source§

fn validate_all(_bytes: &[u8]) -> bool

Source§

impl PackedElement for u64

Source§

fn validate_all(_bytes: &[u8]) -> bool

Implementors§