#parser #untrusted #input #primitive

no-std untrustended

Untrustended - Untrusted Extended. A compilation of primitives for parsing values from untrusted input.

8 releases (4 breaking)

0.4.1 Jan 3, 2024
0.4.0 Jul 19, 2021
0.3.0 Jul 30, 2019
0.2.1 Oct 3, 2017
0.0.2 Jul 23, 2017

#3 in #untrusted

Download history 85/week @ 2024-07-21 143/week @ 2024-07-28 147/week @ 2024-08-04 138/week @ 2024-08-11 110/week @ 2024-08-18 156/week @ 2024-08-25 65/week @ 2024-09-01 102/week @ 2024-09-08 37/week @ 2024-09-15 34/week @ 2024-09-22 95/week @ 2024-09-29 70/week @ 2024-10-06 114/week @ 2024-10-13 208/week @ 2024-10-20 143/week @ 2024-10-27 122/week @ 2024-11-03

588 downloads per month

ISC license

24KB
320 lines

untrustended Crates.ioCircleCI

Untrustended is a compilation of primitives for parsing values from untrusted input. It's building on top of untrusted's Reader::read_byte().

Please, consult untrusted's documentation about how to use that crate before attempting to use this one.

Example

See usage example in untrustended documentation.

License

See LICENSE.txt. ISC license.


lib.rs:

Untrustended - Untrusted Extended.

Untrustended is a compilation of primitives for parsing values from untrusted input. It's building on top of untrusted's Reader::read_byte() and Reader::read_bytes().

Please, consult untrusted's documentation about how to use that crate before attempting to use this one.

To use the new methods provided by this crate:

use untrustended::ReaderExt;

then construct a Reader as usual and enjoy.

Example:

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");
}

Dependencies

~28KB