[][src]Crate safe_bytes

This crate allows reading bytes representation of structs even in presence of padding bytes.

crates docs License License

Simply derive SafeBytes for structures where all field types are SafeBytes implementations. And SafeBytes::safe_bytes would initialize all padding bytes before returning &[u8]. All primitives implement SafeBytes as there is no padding bytes. Additionally some std types implement SafeBytes.

Note that in order to initialize padding bytes SafeBytes::safe_bytes takes mutable reference &mut self. And returns shareable reference &[u8] because not all bitpatterns may be allowed for the type.

Macros

typed_field

Creates TypeField for fieled of the given instance. Can be used to implement PaddingBane::get_fields.

Structs

Field

Basic field information. Enough to fill padding bytes between fields.

TypedField

Field information. Enough to fill padding bytes between fields and inside the fields.

Traits

PaddingBane

This trait must be implemented in order to fill padding bytes of an object.

SafeBytes

Trait for types that can initialize their padding in their bytes representation.

Derive Macros

SafeBytes

Safely implements SafeBytes via PaddingBane implementation.