#parse #dump #serialize #deserialize #stringify

gura

A Gura configuration language serializer/deserializer for Rust

10 unstable releases (3 breaking)

0.4.2 Sep 14, 2021
0.4.1 Sep 13, 2021
0.3.4 Aug 12, 2021
0.2.0 Jul 27, 2021
0.1.0 Jul 15, 2021

#221 in Encoding

Download history 18/week @ 2021-07-12 17/week @ 2021-07-19 36/week @ 2021-07-26 55/week @ 2021-08-02 62/week @ 2021-08-09 31/week @ 2021-08-16 14/week @ 2021-08-23 22/week @ 2021-08-30 36/week @ 2021-09-06 62/week @ 2021-09-13 20/week @ 2021-09-20

103 downloads per month
Used in serde_gura

MIT license

68KB
1.5K SLoC

Gura Rust parser

CI

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.

Documentation - Cargo

Installation

Add the dependency to your Cargo.toml:

[dependencies]
gura = "0.4.2"

Usage

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);
}

Contributing

All kind of contribution is welcome! If you want to contribute just:

  1. Fork this repository.
  2. Create a new branch and introduce there your new changes.
  3. Make a Pull Request!

Or you can join to our community in Discord!

Tests

To run all the tests: cargo test

Licence

This repository is distributed under the terms of the MIT license.

Dependencies

~3MB
~66K SLoC