8 个版本 (4 个重大更新)
0.4.1 | 2024年1月3日 |
---|---|
0.4.0 | 2021年7月19日 |
0.3.0 | 2019年7月30日 |
0.2.1 | 2017年10月3日 |
0.0.2 | 2017年7月23日 |
#5 in #untrusted
每月388次下载
24KB
320 行
untrustended 

Untrustended 是从未授权输入解析值的原语集合。它建立在 untrusted 的 Reader::read_byte()
和 Reader::read_bytes()
之上。
在使用此库之前,请先查阅 untrusted 的文档。
示例
请参阅 untrustended 文档 中的使用示例。
许可证
请参阅 LICENSE.txt。ISC 许可证。
lib.rs
:
Untrustended - Untrusted 扩展。
Untrustended 是从未授权输入解析值的原语集合。它建立在 untrusted 的 Reader::read_byte()
和 Reader::read_bytes()
之上。
在使用此库之前,请先查阅 untrusted 的文档。
要使用此库提供的新的方法
use untrustended::ReaderExt;
然后像平常一样构建一个 Reader
并享受它。
示例
use untrusted::{Input, Reader};
use untrustended::{ReaderExt, Error};
fn read_stuff(input: &mut Reader<'_>) -> Result<(u8, u16, u32), Error> {
let one_byte = input.read_u8()?;
let big_endian_u16 = input.read_u16be()?;
let little_endian_u32 = input.read_u32le()?;
Ok((one_byte, big_endian_u16, little_endian_u32))
}
fn main() {
let buf = vec![0, 1, 2, 3, 4, 5, 6];
let input = Input::from(&buf);
input.read_all(Error::UnknownError, read_stuff).expect("read_all to succeed");
}
依赖项
~28KB