Expand description
This crate allows reading bytes representation of structs even in presence of padding bytes.
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
TypeFieldfor fieled of the given instance. Can be used to implementPaddingBane::get_fields.
Structs§
- Field
- Basic field information. Enough to fill padding bytes between fields.
- Typed
Field - Field information. Enough to fill padding bytes between fields and inside the fields.
Traits§
- Padding
Bane - This trait must be implemented in order to fill padding bytes of an object.
- Safe
Bytes - Trait for types that can initialize their padding in their bytes representation.
Derive Macros§
- Safe
Bytes - Safely implements
SafeBytesviaPaddingBaneimplementation.