Crate dangerous[][src]

Expand description

Safely and explicitly parse untrusted aka dangerous data.

Basic usage

use dangerous::{Input, 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"))));

Feature flags

FeatureDefaultDescription
stdEnabledEnables std::error::Error support and alloc
allocEnabledEnables allocations.
simdEnabledEnables all supported SIMD optimisations.
unicodeEnabledEnables improved unicode printing support.
full-backtraceEnabledEnables collection of all contexts for Expected.
zcDisabledEnables zc crate support.
nomDisabledEnables nom crate error support.
regexDisabledEnables regex pattern support.

Modules

display

Display support.

error

Error support.

Structs

Bytes

Raw Input.

Expected

An error that Details what went wrong while reading and may be retried.

Fatal

An error that has no details around what went wrong and cannot be retried.

Invalid

An error that has no details around what went wrong other than a RetryRequirement if the error is not fatal.

Peek

Peek of Input.

Reader

Created from and consumes an Input.

Span

Range of Input.

String

UTF-8 Input.

Enums

Bound

Indication of whether Input will change in futher passes.

MaybeString

String if known UTF-8, Bytes if not.

Traits

Error

Auto-trait for WithContext, ToRetryRequirement and From<Expected(Value/Length/Valid)>.

Input

Implemented for immutable wrappers around bytes to be processed (Bytes/String).

Pattern

Implemented for structures that can be found within an Input.

ToRetryRequirement

Implemented for errors that return a RetryRequirement.

Functions

input

Creates a new Input from a byte or string slice.

Type Definitions

BytesReader

Bytes specific Reader.

StringReader

String specific Reader.