| Crates.io | oak-toml |
| lib.rs | oak-toml |
| version | 0.0.1 |
| created_at | 2025-10-22 04:33:00.981894+00 |
| updated_at | 2026-01-23 05:20:24.89982+00 |
| description | High-performance incremental TOML parser for the oak ecosystem with flexible configuration, optimized for configuration files and data serialization. |
| homepage | https://github.com/ygg-lang/oaks |
| repository | https://github.com/ygg-lang/oaks |
| max_upload_size | |
| id | 1894947 |
| size | 80,621 |
High-performance incremental TOML parser for the oak ecosystem with flexible configuration, optimized for configuration file processing and data serialization.
Oak of toml is a robust parser for TOML, designed to handle complete TOML syntax including modern features. Built on the solid foundation of oak-core, it provides both high-level convenience and detailed AST generation for configuration processing and data serialization.
Basic example:
use oak_toml::TomlParser;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let parser = TomlParser::new();
let toml_content = r#"
[package]
name = "oak-toml"
version = "0.1.0"
authors = ["Oak Contributors"]
"#;
let document = parser.parse_document(toml_content)?;
println!("Parsed TOML document successfully.");
Ok(())
}
use oak_toml::{TomlParser, ast::Document};
let parser = TomlParser::new();
let toml_content = r#"
[server]
host = "localhost"
port = 8080
[database]
url = "postgresql://localhost/mydb"
pool_size = 10
"#;
let document = parser.parse_document(toml_content)?;
println!("Server config: {:?}", document.get_table("server"));
use oak_toml::{TomlParser, ast::Table};
let parser = TomlParser::new();
let table_content = r#"
[package]
name = "my-project"
version = "1.0.0"
description = "A sample project"
"#;
let table = parser.parse_table(table_content)?;
println!("Package name: {:?}", table.get_value("name"));
use oak_toml::{TomlParser, lexer::Token};
let parser = TomlParser::new();
let tokens = parser.tokenize("key = 'value'\narray = [1, 2, 3]")?;
for token in tokens {
println!("{:?}", token.kind);
}
use oak_toml::TomlParser;
let parser = TomlParser::new();
let invalid_toml = r#"
[section
key = "value"
"#;
match parser.parse_document(invalid_toml) {
Ok(document) => println!("Parsed TOML document successfully."),
Err(e) => {
println!("Parse error at line {} column {}: {}",
e.line(), e.column(), e.message());
if let Some(context) = e.context() {
println!("Error context: {}", context);
}
}
}
The parser generates a comprehensive AST with the following main structures:
Oak of toml integrates seamlessly with:
Check out the examples directory for comprehensive examples:
Contributions are welcome!
Please feel free to submit pull requests at the project repository or open issues.