Crates.io | safe-bytes |
lib.rs | safe-bytes |
version | 0.1.1 |
source | src |
created_at | 2020-06-18 17:53:16.026149 |
updated_at | 2020-06-18 18:06:32.401327 |
description | Helper crate to read bytes representation of structs safely |
homepage | |
repository | https://github.com/zakarumych/safe-bytes |
max_upload_size | |
id | 255419 |
size | 20,291 |
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.
This repository is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.