taped
A lightweight cursor for non-linear parsing of byte slices.
Documentation
Overview
Tape wraps a byte slice with a position cursor, providing methods for
scanning, backtracking, and consuming bytes without allocating.
- Optimized character and string search via
memchr- Controlled by
intrinsicsfeature flag
- Controlled by
- Simple lookahead and lookbehind of whitespace characters
- Indentation counting and paragraph/line awareness
Originally developed as the byte reader for bincake,
extracted as a standalone primitive after the same pattern appeared
across multiple projects.
Example
use Tape;
let data = b"hello world";
let mut tape = new;
tape.seek; // advance to space
let word = tape.consume; // consume "hello"
assert_eq!;
When to use this
- Writing a parser for a binary or text format
- Scanning byte sequences without regex or
nom - Anywhere you need backtracking via cheap position snapshots (
tape.clone())
When not to use this
- Full parser combinator framework → use
nomorwinnow - Lexer generation → use
logos - Async byte streams → use
tokio::io::AsyncBufRead