[dependencies]
fasrt = "0.2"- Zero-copy, zero-allocation parsing — borrows directly from the input string
#![no_std]support (with optionalallocandstdfeatures)- Lazy iterator-based parsing — blocks are yielded on demand
- DFA-based lexing via
logosfor fast tokenization - Strongly-typed newtypes (
Hour,Minute,Second,Millisecond,Percentage) with compile-time validation - W3C WebVTT spec conformant — validated against Web Platform Tests
- Strict and lossy parsing modes
- Timestamps (
HH:MM:SS,mmm) - Multiline cue bodies
- Writer (
stdfeature)
- WEBVTT signature and header text
- Timestamps (short
MM:SS.mmmand longHH:MM:SS.mmmforms, unbounded hours) - Cue identifiers (zero-copy
&str) - Cue settings (
vertical,line,position,size,align,region) - NOTE, STYLE, REGION blocks
- Full REGION definition parsing (
id,width,lines,regionanchor,viewportanchor,scroll) - Float percentages (e.g.,
50.5%) - CRLF, CR, LF line endings
- BOM handling
- Error recovery (
-->in cue body, malformed timing lines) - Writer with round-trip fidelity (
stdfeature) - Cue text parsing — two-layer design:
CueParser: logos DFA-backed, zero-alloc token stream (no_std)CueText: W3C spec-compliant DOM tree builder withNode/TagNodetypes (alloc/std)- Tags:
<b>,<i>,<u>,<c>,<ruby>,<rt>,<v>,<lang>, with classes and annotations - W3C tree building algorithm: implied end tags,
<rt>scoping, unterminated tag handling - Full HTML5 named character reference support (2,231 entities via
phfperfect hash map) - Numeric (
 ) and hexadecimal ( ) character references - Lazy text normalization via
CueStrwithOnceCell-cached decoding and NULL (U+0000 → U+FFFD) replacement
| Feature | Default | Description |
|---|---|---|
std |
Yes | Enables std::io writer and thiserror::Error impls |
alloc |
No | Enables CueText DOM tree and entity decoding without std |
memchr |
Yes (via alloc/std) |
SIMD-accelerated fast path for entity decoding |
Measured on Apple Silicon with cargo bench (Criterion).
| Benchmark | Input | Time | Throughput |
|---|---|---|---|
| Parse (strict) | 2 cues, 89 B | ~170 ns | 520 MiB/s |
| Parse (strict) | 26 KB file | ~38 µs | 661 MiB/s |
| Parse (lossy) | 332 files, ~8 MB | ~12.1 ms | 646 MiB/s |
Collect into Vec |
26 KB file | ~40 µs | 616 MiB/s |
| Benchmark | Input | Time | Throughput |
|---|---|---|---|
| Parse | 2 cues, 96 B | ~318 ns | 291 MiB/s |
| Parse | Settings + region + style, 354 B | ~915 ns | 387 MiB/s |
| Parse | All WPT fixtures, ~34 KB | ~113 µs | 314 MiB/s |
Collect into Vec |
Settings + region + style, 354 B | ~973 ns | 364 MiB/s |
| Benchmark | Input | Time | Throughput |
|---|---|---|---|
| Parse | Tags only, 166 B | ~316 ns | 552 MiB/s |
| Parse | 500 timestamps, ~11 KB | ~14.1 µs | 776 MiB/s |
Run benchmarks yourself:
cargo benchfasrt is under the terms of both the MIT license and the
Apache License (Version 2.0).
See LICENSE-APACHE, LICENSE-MIT for details.
Copyright (c) 2026 FinDIT Studio authors.