Skip to content

aeckar/taped

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

taped

A lightweight cursor for non-linear parsing of byte slices.

Rust Crates.io

Documentation

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
    • 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, extracted as a standalone primitive after the same pattern appeared across multiple projects.

Example

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
  • Anywhere you need backtracking via cheap position snapshots (tape.clone())

When not to use this

About

A lightweight cursor for non-linear parsing of slices.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages