Skip to main content

High-performance Gel syntax parser transforming to JSON/XML (Rust + PyO3)

Project description

Rustine

CI PyPI Docs License

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
  • 10–19× 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 errorsGelError with source spans (line, column, offset)
  • Semantic validation — regex pre-validation, inheritance checks, undefined grammar/variable warnings
  • Python bindings — PyO3 + maturin, installable via pip
  • CLI toolrgel binary 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rustine-0.1.1.tar.gz (103.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rustine-0.1.1-cp39-abi3-win_amd64.whl (916.1 kB view details)

Uploaded CPython 3.9+Windows x86-64

rustine-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

rustine-0.1.1-cp39-abi3-macosx_11_0_arm64.whl (866.8 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

rustine-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl (927.3 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

rustine-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file rustine-0.1.1.tar.gz.

File metadata

  • Download URL: rustine-0.1.1.tar.gz
  • Upload date:
  • Size: 103.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rustine-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0d0ebf7c1b931328e20e8f6f6463f6e1fdc44a73ab3ef43b26c7fa2b90509928
MD5 23e94f318c90cee334b9248d1bdb450e
BLAKE2b-256 0898be5e499f038481f7d6e0100e2140c42bb6c180ad60a61a6dbddc8aa46d43

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.1.1.tar.gz:

Publisher: release.yml on bigmars86/rustine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustine-0.1.1-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: rustine-0.1.1-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 916.1 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

Hashes for rustine-0.1.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 da3cab5413fdef5029a1b6d53625f3f40d23ba9e70c4f321ba2ea7fa076b60e4
MD5 db89ff548de4a8560931db06fdd12008
BLAKE2b-256 024baab76dd9b042cba1ff6c7cb777494864b9eef18f79702fa717ab805a9761

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.1.1-cp39-abi3-win_amd64.whl:

Publisher: release.yml on bigmars86/rustine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustine-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rustine-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ca5b668647ce7f33a31810cbc4f446438410ed86f52cfcc3d4e1937c00d6c07c
MD5 627a831c5b2ff81a29c5dd90255cdea8
BLAKE2b-256 50001eafcc6e171227d0ea769098d40d97b15b5899577ac29e944452b10c2299

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.1.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on bigmars86/rustine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustine-0.1.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustine-0.1.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0839bbb046b5b252be07df8e3cc25422a29a528d9ed3a1ea81cafb72353fd75a
MD5 050ca76b30a28d4cdcbdd9ce6a05aa64
BLAKE2b-256 4e5c759b67b94b794fa51cd6fcdd7dca287562d289dc32cb6e41820b784ec9c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.1.1-cp39-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on bigmars86/rustine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustine-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustine-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 462d5644a6b229d7c66595e0939248d6fcff72e530fb8b17682c0098a9de4a5a
MD5 e0f1cdd0aef5164ea7b3d200ac4e40ec
BLAKE2b-256 d8f2f5b95bf8eb7067db8b6db5abbdd2bd18e3af49717721d5748ee059e1f51c

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.1.1-cp39-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on bigmars86/rustine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rustine-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustine-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 518daf30e7007bf80193af50a018204c7f35e42adbc8f894eeac1828ade4e24c
MD5 5b07d13557e1e0f9488f69c2d8c8d82c
BLAKE2b-256 70c733a85910d7ae90879cc80de2849819ca77edb880e52e5fd35d65496d70d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release.yml on bigmars86/rustine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page