Crates.io | static-bytes |
lib.rs | static-bytes |
version | 0.3.0 |
source | src |
created_at | 2020-08-31 23:00:53.812243 |
updated_at | 2021-01-05 15:20:38.191659 |
description | Bytes for embedded devices |
homepage | |
repository | https://github.com/xoac/static-bytes |
max_upload_size | |
id | 283253 |
size | 31,635 |
The aim of this crate is to improve user experience when working with static bytes.
Look at this pseudo code example to understand problem with &mut [u8]
and bytes::buf::BufMut
let mut fixed_storage = [u8; 16];
let mut slice = fixed_storage[..];
let len_before = slice.len();
// declaration fn encode(&self, buf: &mut dyn BufMut);
frame.encode(&mut slice);
let len = len_before - slice.len();
let filled_bytes = fixed_storage[..len];
There are two problems with code above:
You can resolve both with SafeBytesSlice
. For example usage see
docs.
v0.1.x is compatible with bytes >=0.5.0, <0.6.0
v0.2.x is compatible with bytes >=0.6.0, <0.7.0
v0.3.x is compatible with bytes >=0.1.0, <2.0.0
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.
This project try follow rules:
This README was generated with cargo-readme from template