HUML Parser for Rust
This is a Rust library for the HUML (Human-Usable Markup Language) data serialization format.
Features
- Serde Support: Full bidirectional support - serialize Rust structs to HUML and deserialize HUML into Rust structs.
- Full compliant with HUML specification
- Supports all HUML data types (string, number, boolean, array, object)
- Handles comments and whitespace correctly
Usage
Add this to your Cargo.toml:
[]
= "0.1.0" # Replace with the desired version
= { = "1.0", = ["derive"] }
You can find the crate on crates.io.
Low-level Parsing
Then, you can parse a HUML string like this:
use parse_huml;
Serde Integration (Serialization & Deserialization)
HUML-rs provides full bidirectional serde support for seamless integration with Rust structs.
Deserializing HUML into Rust Structs
use from_str;
use Deserialize;
Serializing Rust Structs to HUML
use to_string;
use Serialize;
Round-trip Serialization
HUML maintains perfect round-trip fidelity:
use ;
use ;
let original = Data ;
// Serialize to HUML
let huml = to_string.unwrap;
// Deserialize back to struct
let restored: Data = from_str.unwrap;
assert_eq!; // Perfect round-trip!
Development
This project is built with Rust using a hand-written recursive descent parser inspired by Go's parsing style.
To build the project:
To run tests:
Standard HUML Test Suite
This parser includes the official HUML test suite as a git submodule, which contains centrally maintained test cases that all HUML parser implementations should pass. These tests help ensure compatibility and correctness across different parsers.
To initialize the test submodule:
The standard tests include:
- Assertion Tests: 174+ test cases covering valid and invalid HUML syntax
- Document Tests: Complete HUML documents with expected JSON output for validation
To run only the standard tests:
Current Status:
- ✅ All document parsing tests pass
- ✅ All assertion tests pass (174+ test cases)
To run benchmarks:
Benchmarking
This project includes comprehensive benchmarks using Criterion.rs to measure parsing performance across different scenarios:
Benchmark Categories
- Full Document Parsing: Measures performance parsing the complete
test.humlfile - Component Parsing: Tests individual parsing functions (strings, numbers, booleans, etc.)
- Collection Parsing: Benchmarks inline and multiline lists/dictionaries
- Multiline Strings: Tests multiline string parsing with preserved formatting
- Document Sizes: Compares performance across small, medium, and large documents
- Edge Cases: Tests long strings, deep nesting, and large collections
- Memory Usage: Measures allocation patterns and repeated parsing
Running Benchmarks
# Run all benchmarks (HTML reports automatically generated)
# Run specific benchmark group
# View HTML reports in target/criterion/reports/index.html
Contributing
Contributions are welcome! Please feel free to open an issue or submit a pull request.