Crates.io | gura |
lib.rs | gura |
version | 0.5.4 |
source | src |
created_at | 2021-07-15 19:32:43.397691 |
updated_at | 2024-04-01 18:09:34.142952 |
description | A Gura configuration language serializer/deserializer for Rust |
homepage | |
repository | https://github.com/gura-conf/gura-rs-parser |
max_upload_size | |
id | 423197 |
size | 133,199 |
IMPORTANT: if you need to use Gura in a more user-friendly way, you have at your disposal Serde Gura which allows you to perform Serialization/Deserialization with ease.
This repository contains the implementation of a Gura (compliant with version 1.0.0) format parser for Rust lang.
Add the dependency to your Cargo.toml
:
[dependencies]
gura = "0.5.4"
use gura::{dump, parse, GuraType};
fn main() {
let gura_string = r##"
# This is a Gura document.
title: "Gura Example"
an_object:
username: "Stephen"
pass: "Hawking"
# Line breaks are OK when inside arrays
hosts: [
"alpha",
"omega"
]"##;
// Parse: transforms a Gura string into a dictionary
let parsed = parse(&gura_string).unwrap();
// Debug and Display
// println!("{:#?}", parsed);
// println!("{}", parsed);
// Access a specific field
println!("Title -> {}", parsed["title"]);
// Iterate over structure
println!("\nHosts:");
if let GuraType::Array(hosts) = &parsed["hosts"] {
for host in hosts.iter() {
println!("Host -> {}", *host);
}
}
// Dump: transforms a dictionary into a Gura string
let string_again = dump(&parsed);
println!("\n+++++ Dump result +++++");
println!("{}", string_again);
}
All kind of contribution is welcome! If you want to contribute just:
Or you can join to our community in Discord!
To run all the tests: cargo test
This repository is distributed under the terms of the MIT license.