formatparse-core
Pure Rust library for parsing strings using Python format()-style patterns.
This crate holds the language-agnostic logic: field specifications, regex construction from those specs, datetime microsecond helpers, input normalization (line continuations, indent stripping), and safety limits. It has no dependency on Python or PyO3, so it is suitable for:
- Running
cargo testwithout a Python install - Embedding in other Rust projects
- Building non-Python bindings on top of the same engine
Modules (public surface)
The crate root re-exports the main building blocks; see src/lib.rs for the full list. Highlights:
| Module | Role |
|---|---|
types |
FieldType, FieldSpec, and regex fragments for each field kind |
types::regex |
Helpers such as strftime_to_regex |
parser |
Length/name validation, build_regex / search-regex helpers (parser::regex) |
datetime |
Microsecond digit parsing shared with bindings |
error |
FormatParseError and related messages |
indent_block |
Strip common leading indent from captured block text |
input_line_continuations |
Normalize backslash line continuations in input |
Testing
Usage
The primary consumer is the formatparse-pyo3 crate (Python extension). You can also use formatparse-core directly:
use ;
let spec = FieldSpec ;
Or use FieldSpec::default() / FieldSpec::new() and mutate the fields you need.