scursor
Secure cursor library with support for read and write transactions.
Panic-free design
scursor is designed to be strictly panic-free. This makes it suitable for parsing untrusted input
in security-sensitive contexts, embedded systems with panic = "abort", or anywhere predictable
failure handling is required.
The ReadCursor uses a consumption model where each read operation advances an internal position
within a borrowed byte slice. The key insight is that all operations use inherently safe methods.
For example, the core read_array routine is implemented as:
Higher-level routines are composed from these primitives. There are no direct slice indexing
operations (slice[i]), no .unwrap() or .expect() calls, and no arithmetic that could overflow.
Every failure path returns a Result.
Safety by Composition
The core philosophy of scursor is that complexity should be built from verified, safe foundations.
You can build complex, multi-step parsers that inherit the library's panic-free guarantees:
use ;
Formal Verification
This library is formally verified to be panic-free using the Kani Rust Verifier. Kani uses bit-precise model checking to mathematically prove the absence of panics, out-of-bounds accesses, and overflows across all possible execution paths and inputs.
To run the mathematical proofs yourself:
-
Install Kani:
-
Run Verification:
License
Licensed under the terms of the MIT or Apache v2 licenses at your choice.