| Crates.io | jute-parser |
| lib.rs | jute-parser |
| version | 0.1.0 |
| created_at | 2025-12-17 15:21:59.618703+00 |
| updated_at | 2025-12-17 15:21:59.618703+00 |
| description | A Rust code generator and parser for Apache Jute schemas |
| homepage | https://github.com/Lovepreet67/jute-parser |
| repository | https://github.com/Lovepreet67/jute-parser |
| max_upload_size | |
| id | 1990524 |
| size | 70,163 |
A Rust implementation of the Apache ZooKeeper Jute IDL, providing a compiler-grade solution for protocol schema parsing and code generation.
This crate is designed for compiler-grade correctness, not just simple code generation, ensuring your generated code is based on a fully validated schema.
module, class, primitive types, vector<T>, map<K, V>, and cross-module type references.include "./path.jute";).Create a schema file, e.g., schema/serialization.jute:
module serialization {
class Person {
int id;
string name;
boolean active;
}
class Company {
int id;
Person owner;
vector<Person> employees;
}
}
Use the JuteGenerator to process your schema and generate source files:
use jute::JuteGenerator;
JuteGenerator::new()
.add_src_file("schema/serialization.jute") // Input schema
.add_out_dir("generated") // Output directory src (curr crate) will be used as root
.generate()
.unwrap();
The generated code is not automatically wired into your crate. You must include it manually:
// src/lib.rs or src/main.rs
pub mod serialization {
include!("generated/serialization/mod.rs");
}
All generated types implement two core methods for I/O-based serialization:
fn serialize<W: std::io::Write>(&self, out: &mut W) -> Result<(), JuteError>;
fn deserialize<R: std::io::Read>(input: &mut R) -> Result<Self, JuteError>;
Example Round-Trip:
use crate::serialization::{Person, Company};
let person = Person {
id: 1,
name: "Alice".into(),
active: true,
};
let mut buffer = Vec::new();
// Serialize
person.serialize(&mut buffer).unwrap();
// Deserialize
let decoded = Person::deserialize(&mut &buffer[..]).unwrap();
assert_eq!(decoded.id, 1);
// ... more assertions
A complete end-to-end example demonstrating how to use this crate is available here:View the full E2E example
Includes are resolved relative to the file that contains the include directive:
include "./common.jute";
include "../shared/types.jute";
The resolver ensures all paths are:
All failures return a unified, descriptive error type:
use jute::errors::JuteError;
Errors are descriptive and contextual, including file paths and module names. They cover:
The project follows a classic compiler architecture:
src/
โโโ compiler/
โ โโโ ast_printer.rs // utility
โ โโโ ast.rs
โ โโโ dependency_resolver.rs
โ โโโ lexer.rs
โ โโโ parser.rs
โ โโโ state_machine.rs
โ โโโ token.rs
โ โโโ mod.rs
โโโ code_generator/
โ โโโ rust/
โ | โโโ utilities.rs
โ | โโโ writer.rs
โ | โโโ mod.rs
โ โโโ mod.rs
โโโ errors.rs
โโโ lib.rs
This crate prioritizes stability and correctness:
It is intended for:
Following features are currently not supported
Containerized recursive schema
Can be enhanced with async versions of serialization.
This project is licensed under the MIT License.
Contributions are welcome! Focus areas include: