High-performance Gel syntax parser transforming to JSON/XML (Rust + PyO3)
Project description
Rustine
High-performance Gel syntax parser that transforms unstructured text into JSON, XML, or YAML. A complete Rust rewrite of Python Gelatin, usable as a native Python module, a Rust library, or a standalone CLI tool.
Why Rustine?
Gelatin has been a reliable tool for converting network device output and other semi-structured text into structured data. However, its core dependency — SimpleParse — has not been updated for Python 3.12+ and is no longer maintained. This made Gelatin incompatible with modern Python versions.
Rustine solves this by reimplementing the entire Gelatin engine in Rust:
- Drop-in replacement — same Gel grammar language, same output format
- 17–46× faster than Python Gelatin (depending on workload and platform)
- 3–4× less memory on large inputs
- Works on Python 3.9–3.13+ via PyO3 — no C extension dependency
- 100% feature parity with the original Python implementation
Quick Start
Python
pip install rustine
from Rustine import rustine
grammar = r"""
define nl /\r?\n/
define ws /\s+/
grammar input:
match 'Name:' ws /[^\r\n,]+/ /(?:\r?\n|,) */:
out.open('user')
out.add_attribute('.', 'name', '$2')
match /[\w ]+/ ':' ws /[^\r\n,]+/ /(?:\r?\n|,) */:
out.add('$0', '$3')
match nl:
do.return()
"""
input_text = "Name: Alice\nAge: 30\nOffice: 1st Ave\n"
print(rustine.parse_to_json(grammar, input_text))
Rust
cargo add rustine --no-default-features
use rustine::exec::{execute, serialize_execution, RuntimeFormat};
let result = execute(grammar_source, input_text);
let json = serialize_execution(&result, RuntimeFormat::Json);
CLI
cargo install rustine --features cli
rgel -s syntax.gel -f json input.txt
rgel -s syntax.gel -f xml input.txt
rgel -s syntax.gel -f yaml input.txt
Performance
Benchmarked on 20.9 MB real-world IOS XR configuration (263 grammars, 113 regex patterns, 899 757 output nodes):
| Tool / Platform | Time | Throughput | Peak RSS |
|---|---|---|---|
| Python Gelatin (Win) | 66.3 s | 0.33 MB/s | 3 075 MB |
| Rustine (Win) | 4.10 s | 5.1 MB/s | 496 MB |
| Rustine (jemalloc) | 2.31 s | 9.1 MB/s | 456 MB |
| Comparison | Speedup |
|---|---|
| Rustine vs Python Gelatin (scale) | 17–19× |
| Rustine vs Python Gelatin (CLI) | 11–13× |
| Rustine vs textfsm (25 MB) | 1.6× |
See BENCHMARKS.md for full cross-platform results (Windows, Linux glibc, Linux jemalloc), serialization timings, and reproduction instructions.
Alternatives
| Tool | Approach | Output | vs Rustine |
|---|---|---|---|
| textfsm | Line-by-line FSM templates | Flat tables (list of dicts) | Simpler for quick extraction; no hierarchy, no nesting, pure Python |
| TTP | Template-based parsing | Nested dicts | Flexible templates; Python-only, slower on large inputs |
| Napalm | Device abstraction + textfsm | Flat dicts per getter | Higher-level (device drivers); not a general text parser |
| PyATS/Genie | Model-driven parsing | Structured models | Cisco ecosystem; heavy dependencies, not general-purpose |
| nom / pest | Rust parser combinators / PEG | Custom AST | Maximum flexibility; requires writing a parser in code, no DSL file |
Rustine's niche: a grammar-driven text→tree transformer with a concise DSL
(.gel files), hierarchical output, and native performance. It sits between
simple template extractors (textfsm) and full parser generators (nom/pest).
Feature Highlights
- Gel grammar language — match, imatch, when, skip, define, grammar inheritance
- Rich output actions — create, add, replace, add_attribute, open, enter, leave, set_root_name
- Trigger system — enqueue_before/after/on_add/on_leave (single-shot and persistent)
- Captures — positional (
$1,$2) and named ($name) with interpolation in paths and values - Three output formats — JSON, XML, YAML
- Streaming execution — feed chunks incrementally via
StreamingRunner - Structured errors —
GelErrorwith source spans (line, column, offset) - Semantic validation — regex pre-validation, inheritance checks, undefined grammar/variable warnings
- Python bindings — PyO3 + maturin, installable via
pip - CLI tool —
rgelbinary for shell pipelines
Cargo Features (compile-time)
Features are selected at build time via --features and control which
capabilities are compiled into the binary.
See Getting Started → Cargo Features
for the full table and usage examples.
Key features: cli, jemalloc (default in Linux wheels), mimalloc,
mmap, parallel, python (default).
Documentation
| Document | Description |
|---|---|
| Getting Started | Installation, first steps, Python/Rust/CLI usage |
| Gel Syntax Reference | Grammar language, statements, actions, triggers |
| Architecture | Parser pipeline, module layout, design decisions |
| Performance | Optimization techniques, benchmark overview |
| BENCHMARKS.md | Raw benchmark data for all platforms |
| Migration from Gelatin | Drop-in replacement guide, parity notes |
| Contributing | Development setup, coding guidelines, PR process |
| Changelog | Version history |
License
Dual-licensed under MIT or Apache-2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rustine-0.1.0.tar.gz.
File metadata
- Download URL: rustine-0.1.0.tar.gz
- Upload date:
- Size: 104.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3c41a34e746dae753dcbc0d325db9ff67554b294d76b437412f5c138675aa41
|
|
| MD5 |
2d514eccdb7deb9b3ee38f32da031983
|
|
| BLAKE2b-256 |
9de584c7e3c38f42916e051bfca68b0232589145fd9caa7b432445c87fbd8fa8
|
Provenance
The following attestation bundles were made for rustine-0.1.0.tar.gz:
Publisher:
release.yml on bigmars86/rustine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustine-0.1.0.tar.gz -
Subject digest:
a3c41a34e746dae753dcbc0d325db9ff67554b294d76b437412f5c138675aa41 - Sigstore transparency entry: 1168846668
- Sigstore integration time:
-
Permalink:
bigmars86/rustine@3dd7cc307a7b49132dfeff749b3c2ec627b301f6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bigmars86
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3dd7cc307a7b49132dfeff749b3c2ec627b301f6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rustine-0.1.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: rustine-0.1.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 911.8 kB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38307209a0395a15377718cbbf89a3b535c0e6a6fdda3c3306a66d49939135ec
|
|
| MD5 |
b088451f9547d3815fcd360e05c6fbfd
|
|
| BLAKE2b-256 |
b86e30379e6e7ae54aa50e82005a04918480663b6751351559d3df06944c5253
|
Provenance
The following attestation bundles were made for rustine-0.1.0-cp39-abi3-win_amd64.whl:
Publisher:
release.yml on bigmars86/rustine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustine-0.1.0-cp39-abi3-win_amd64.whl -
Subject digest:
38307209a0395a15377718cbbf89a3b535c0e6a6fdda3c3306a66d49939135ec - Sigstore transparency entry: 1168846809
- Sigstore integration time:
-
Permalink:
bigmars86/rustine@3dd7cc307a7b49132dfeff749b3c2ec627b301f6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bigmars86
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3dd7cc307a7b49132dfeff749b3c2ec627b301f6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rustine-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: rustine-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.9+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5191e929afaa7054766734241d68dc7214b29cc482fad1e877ccb61478d5f26a
|
|
| MD5 |
456d6466c5923bd3a5ca8e6251e4abe1
|
|
| BLAKE2b-256 |
c320dabe126608cd6acecff53194d0dff9f9611e728c7904c680f75a86766fc7
|
Provenance
The following attestation bundles were made for rustine-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:
Publisher:
release.yml on bigmars86/rustine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustine-0.1.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl -
Subject digest:
5191e929afaa7054766734241d68dc7214b29cc482fad1e877ccb61478d5f26a - Sigstore transparency entry: 1168847106
- Sigstore integration time:
-
Permalink:
bigmars86/rustine@3dd7cc307a7b49132dfeff749b3c2ec627b301f6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bigmars86
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3dd7cc307a7b49132dfeff749b3c2ec627b301f6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rustine-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: rustine-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 866.8 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cbe6442ecaf5bcb244170a57182b5e52625b13fb7bc32742d12068c31c7c078
|
|
| MD5 |
d469e229efa4221d623b78307044bab5
|
|
| BLAKE2b-256 |
56e427944d6fc121bf1bf38a74c26a24ee97f768aa469ac67180bac211048deb
|
Provenance
The following attestation bundles were made for rustine-0.1.0-cp39-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on bigmars86/rustine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustine-0.1.0-cp39-abi3-macosx_11_0_arm64.whl -
Subject digest:
6cbe6442ecaf5bcb244170a57182b5e52625b13fb7bc32742d12068c31c7c078 - Sigstore transparency entry: 1168847005
- Sigstore integration time:
-
Permalink:
bigmars86/rustine@3dd7cc307a7b49132dfeff749b3c2ec627b301f6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bigmars86
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3dd7cc307a7b49132dfeff749b3c2ec627b301f6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rustine-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: rustine-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 927.2 kB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f3d74a91f258034cf468ec0ef58357e56c186c5d8712e15b83d990ceb43cba6
|
|
| MD5 |
26155dd7aa246ffca06a24f08d97f4ac
|
|
| BLAKE2b-256 |
b5d795a54e175992938d0cc1678f53ef879621700db30520bfb3a2a0d36cdacf
|
Provenance
The following attestation bundles were made for rustine-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on bigmars86/rustine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustine-0.1.0-cp39-abi3-macosx_10_12_x86_64.whl -
Subject digest:
0f3d74a91f258034cf468ec0ef58357e56c186c5d8712e15b83d990ceb43cba6 - Sigstore transparency entry: 1168846898
- Sigstore integration time:
-
Permalink:
bigmars86/rustine@3dd7cc307a7b49132dfeff749b3c2ec627b301f6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bigmars86
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3dd7cc307a7b49132dfeff749b3c2ec627b301f6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rustine-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: rustine-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.2 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08ebea073233ec555ff6ada2a582de01d5fac7f6705b0d1cb8ce61f20a82a4fc
|
|
| MD5 |
b3f72ddeff501847183a0ded8b82d846
|
|
| BLAKE2b-256 |
149134080514e936245e0b9f2c0da6a33f866b77af55f1d17ec57447ed0fdd5f
|
Provenance
The following attestation bundles were made for rustine-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on bigmars86/rustine
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rustine-0.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
08ebea073233ec555ff6ada2a582de01d5fac7f6705b0d1cb8ce61f20a82a4fc - Sigstore transparency entry: 1168846742
- Sigstore integration time:
-
Permalink:
bigmars86/rustine@3dd7cc307a7b49132dfeff749b3c2ec627b301f6 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/bigmars86
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3dd7cc307a7b49132dfeff749b3c2ec627b301f6 -
Trigger Event:
push
-
Statement type: