[][src]Crate dangerous

Safely and explicitly parse untrusted aka dangerous data.

Basic usage

use dangerous::Invalid;

let input = dangerous::input(b"hello");
let result: Result<_, Invalid> = input.read_partial(|r| {
    r.read_u8()
});

assert_eq!(result, Ok((b'h', dangerous::input(b"ello"))));

Modules

display

Display support.

error

Error support

Structs

Expected

A catch-all error for all expected errors supported in this crate.

Input

Input is an immutable wrapper around bytes to be processed.

Invalid

Invalid contains no details around what went wrong other than a RetryRequirement if the error is not fatal.

Reader

A Reader is created from and consumes a Input.

Traits

Error

Convenience trait requiring both FromContext and FromExpected.

FromContext

Implemented for errors that collect contexts.

FromExpected

Convenience trait requiring ExpectedValue, ExpectedLength and ExpectedValid.

ToRetryRequirement

Implemented for errors that return input requirements.

Functions

input

Creates a new Input from a byte slice.