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

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

Macros

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

Structs

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

Traits

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