safe-bytes 0.1.1

Helper crate to read bytes representation of structs safely
Documentation
  • Coverage
  • 45.83%
    11 out of 24 items documented0 out of 10 items with examples
  • Size
  • Source code size: 19.76 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.83 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • zakarumych/safe-bytes
    5 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • zakarumych

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.

License

This repository is licensed under either of

at your option.

Contribution Licensing

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.