Crate untrustended[][src]

Expand description

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.


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


Possible errors raised by ReaderExt.


A trait to abstract the idea of creating a new instance of a type from reading bytes out from Reader.

A trait extending untrusted’s Reader.