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.2.0.tar.gz (106.2 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.2.0-cp39-abi3-win_amd64.whl (904.8 kB view details)

Uploaded CPython 3.9+Windows x86-64

rustine-0.2.0-cp39-abi3-win32.whl (810.8 kB view details)

Uploaded CPython 3.9+Windows x86

rustine-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

rustine-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl (1.1 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

rustine-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

rustine-0.2.0-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (1.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ i686

rustine-0.2.0-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.2.0-cp39-abi3-macosx_11_0_arm64.whl (867.5 kB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

rustine-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl (916.9 kB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for rustine-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1838da7f2c4487275c82b33822a7a5602312e41530d719f1c5d4d1bdcea1112f
MD5 069e0d85d099f3526fc7995e73fb2451
BLAKE2b-256 d0824001281a6eaa7c25f154d88b5f728faf35577a996905025b1532bca8b14e

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.2.0.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.2.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: rustine-0.2.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 904.8 kB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rustine-0.2.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b6756bf428ebe9583cb8b5037dd503441bb8e910fffa46c53c9b744f7a462cdc
MD5 2ded98ffbb6c926753f36f5ecd7ce7ac
BLAKE2b-256 1182c7a5e016156afcb42d0f9eef8295e081e78cd79c84cf6ec425ab4c3423e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.2.0-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.2.0-cp39-abi3-win32.whl.

File metadata

  • Download URL: rustine-0.2.0-cp39-abi3-win32.whl
  • Upload date:
  • Size: 810.8 kB
  • Tags: CPython 3.9+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rustine-0.2.0-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 5733f885c609a7be2e03d08c3bf5cc660175eed4e5014e8a34aaa4c2040c84f7
MD5 36a8c31cbeafcf3f78390e1b6fbfe2f6
BLAKE2b-256 75b44d45bf7dc52e28a3dbc0a30175957877a067852e94c6d28d53a0895cccc3

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.2.0-cp39-abi3-win32.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.2.0-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for rustine-0.2.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 facfc8b20042e3b6e59f4a48f3319b6be1f260c1836e574eeebebbeded334e71
MD5 ed6b4555ad13748f41791a344e656dbc
BLAKE2b-256 087451cdd0fcd758e9ca361585d4524f7ecb6642c529f7ec98fb3509ecb901ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.2.0-cp39-abi3-musllinux_1_2_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.2.0-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for rustine-0.2.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 637653f68c2ed076397918c9ea09a36d19d6918e45f03478ff7df7347754b44c
MD5 019353752791c1d0324b8b1d3299b39d
BLAKE2b-256 36c10891921eadf6484ed801fac7b66f2a681d31b511868499a2d234832fab8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.2.0-cp39-abi3-musllinux_1_2_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.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rustine-0.2.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1bb7e830e57e73eb61404135406edba38082c3157694ddefbe076b5dda5f36b5
MD5 ed1388c18d6f2344c7e3bca24496b870
BLAKE2b-256 9c026a584fe821c2281292b1405abe73dbcb7e6412ab84939f24c206d57234cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.2.0-cp39-abi3-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.

File details

Details for the file rustine-0.2.0-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for rustine-0.2.0-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 3f0c50415d80d78038e330682431d20bc8a47e1d1291fdeac2b01cea3f45ceb9
MD5 43f576857b3f1e21f8703a336b1996d1
BLAKE2b-256 1a3a11abf0f3545fde24844353515ff1d0010705615db3735c865bc0b7570556

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.2.0-cp39-abi3-manylinux_2_17_i686.manylinux2014_i686.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.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for rustine-0.2.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f82d2f2bc1cf5e7d703a6727db53c1a405a2c7e67f66cf9d111027399a1f07c0
MD5 aa032b30937f97fe4e967d78f3804b67
BLAKE2b-256 093b9f145931de04ebae46f8112bf548ca9403cdef390975b188dd71c72da769

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.2.0-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.2.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rustine-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fe0917e2356028a669d170034e149642a8fb410acd4445c2a7f033622c5568a6
MD5 382befbcd788a368be8323c7dada5e54
BLAKE2b-256 0d232eaab1e7ee0c015c047dd171519af727964afd5b31fbb0362f0b03adf410

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.2.0-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.2.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rustine-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5f5ed3835c435aed0e76a186ba88f2da0c1883c5d3e59c19d6e95285f9e5cd81
MD5 cc100c63b352b619dd59768d49f0b7e7
BLAKE2b-256 798aa04255883b8bd1d12ac556053397f2086a5518e45307e43aba064ea65207

See more details on using hashes here.

Provenance

The following attestation bundles were made for rustine-0.2.0-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.

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