byte

所属分类:弱点检测代码
开发工具:Rust
文件大小:0KB
下载次数:0
上传日期:2023-05-07 03:55:03
上 传 者sh-1993
说明:  低级、零拷贝、无恐慌的二进制序列化器和反序列化器。(解析器和编码器)
(A low-level, zero-copy, panic-free, binary serializer and deserializer. (parser and encoder))

文件列表:
.travis.yml (181, 2023-05-06)
Cargo.toml (547, 2023-05-06)
LICENSE (1101, 2023-05-06)
benches/ (0, 2023-05-06)
benches/lib.rs (3664, 2023-05-06)
src/ (0, 2023-05-06)
src/ctx/ (0, 2023-05-06)
src/ctx/bool.rs (461, 2023-05-06)
src/ctx/bytes.rs (2910, 2023-05-06)
src/ctx/mod.rs (136, 2023-05-06)
src/ctx/num.rs (3549, 2023-05-06)
src/ctx/str.rs (2835, 2023-05-06)
src/lib.rs (13106, 2023-05-06)
tests/ (0, 2023-05-06)
tests/lib.rs (10604, 2023-05-06)

# `Byte` [![build status](https://travis-ci.org/andylokandy/byte.svg?branch=master)](https://travis-ci.org/andylokandy/byte) [![crates.io](https://img.shields.io/crates/v/byte.svg)](https://crates.io/crates/byte) [![docs.rs](https://docs.rs/byte/badge.svg)](https://docs.rs/byte) A low-level, zero-copy and panic-free binary serializer and deserializer. ### [**Documentation**](https://docs.rs/byte) ## Usage Add the following to your `Cargo.toml`: ```toml [dependencies] byte = "0.2" ``` `Byte` is a `no_std` library; it can be used in any `#![no_std]` situation or crate. # Overview `Byte` is designed to encode or decode binary data in a fast and low-level way. A classical use case is I2C communication en/decoding. `Byte` provides two core traits `TryRead` and `TryWrite`. Types that implement these traits can be serialized into or deserialized from byte slices. The library is meant to be simple, and it will always be. # Example ```rust use byte::*; let bytes: &[u8] = &[0xde, 0xad, 0xbe, 0xef]; let offset = &mut 0; let num = bytes.read_with::(offset, BE).unwrap(); assert_eq!(num, 0xdeadbeef); assert_eq!(*offset, 4); ``` ```rust use byte::*; use byte::ctx::{Str, NULL}; let bytes: &[u8] = b"hello, world!\0dump"; let offset = &mut 0; let str = bytes.read_with::<&str>(offset, Str::Delimiter(NULL)).unwrap(); assert_eq!(str, "hello, world!"); assert_eq!(*offset, 14); ``` ## Contribution All kinds of contribution are welcomed. - **Issues.** Feel free to open an issue when you find typos, bugs, or have any question. - **Pull requests.** New collection, better implementation, more tests, more documents and typo fixes are all welcomed. ## License Licensed under MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)

近期下载者

相关文件


收藏者