Crate transduce

Source
Expand description

Zero-copy isomorphic parsing: your code should look like what it parses.

§Examples

Want to parse something in parentheses? Surround it in parentheses:

use transduce::base::*;
let parser = exact(&b'(') >> anything() << exact(&b')') << end();
let input = b"(*)";
assert_eq!(
    parser.parse(input),
    Ok(&b'*'), // Reference to the region of input inside parentheses
);

Modules§

base
Common functions to drop in instead of reinventing the wheel.
print_error
Trait for pretty-printing parse errors.

Macros§

bail
Immediately return with an error. The second argument requests the slice of input after this error, so we can deduce where it happened.
format_if_alloc
Heap-allocated custom formatting if alloc is enabled; otherwise, use the first, non-heap argument.

Structs§

Both
Perform two actions in order and return both of their results as a tuple.
DiscardLeft
Perform two actions in order and discard the result of the first, returning the result of the second.
DiscardRight
Perform two actions in order and discard the result of the second, returning the result of the first.
Either
Perform two actions in order and return the first one to succeed, or the second error if neither succeed.
ParseError
Parsing error: both a message and where it was, via accepting the length of input after the error.
Parser
Wrapper around a parser to work with the orphan rule.
Pipe
Perform a parsing action then pipe its output into a non-parsing function.

Traits§

Parse
Parse a slice of Inputs into an Output.
Read
Read a series of items (of generic type Input) into this type.