https://github.com/aeckar/taped
A lightweight cursor for non-linear parsing of slices.
https://github.com/aeckar/taped
cursor data-structures iter parsing pointer
Last synced: about 6 hours ago
JSON representation
A lightweight cursor for non-linear parsing of slices.
- Host: GitHub
- URL: https://github.com/aeckar/taped
- Owner: aeckar
- License: mit
- Created: 2026-05-31T05:37:09.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-05-31T06:47:37.000Z (about 1 month ago)
- Last Synced: 2026-05-31T08:05:57.368Z (about 1 month ago)
- Topics: cursor, data-structures, iter, parsing, pointer
- Language: Rust
- Homepage: https://crates.io/crates/taped
- Size: 14.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# taped
A lightweight cursor for non-linear parsing of byte slices.
[](https://github.com/aeckar/taped/actions/workflows/rust.yml)
[](https://crates.io/crates/taped)
## Documentation
[https://docs.rs/taped](https://docs.rs/taped)
## 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`](https://github.com/BurntSushi/memchr)
- Controlled by `intrinsics` feature flag
- Simple lookahead and lookbehind of whitespace characters
- Indentation counting and paragraph/line awareness
Originally developed as the byte reader for [`bincake`](https://github.com/aeckar/bincake),
extracted as a standalone primitive after the same pattern appeared
across multiple projects.
## Example
```rust
use taped::ToTape;
let data = b"hello world!";
let mut tape = data.to_tape();
tape.seek(|ch, _| ch == b' '); // advance to space
tape.adv(); // skip one character
let word = tape.consume(|ch, _| ch != b'!'); // consume "hello"
assert_eq!(word, b"hello");
assert_eq!(tape.rest(), b"!");
```
## When to use this
- Writing a parser for a binary or text format
- Scanning byte sequences without regex or [`nom`](https://github.com/rust-bakery/nom)
- Anywhere you need backtracking via cheap position snapshots (`tape.clone()`)
## When not to use this
- Full parser combinator framework → use [`nom`](https://github.com/rust-bakery/nom) or [`winnow`](https://github.com/winnow-rs/winnow)
- Lexer generation → use [`logos`](https://github.com/maciejhirsz/logos)
- Async byte streams → use [`tokio::io::AsyncBufRead`](https://docs.rs/tokio/latest/tokio/io/trait.AsyncBufRead.html)