Serde Gura

CI

This crate is a Rust library for using the [Serde] serialization framework with data in [Gura] file format.

This library does not re-implement a Gura parser; it uses the [gura-rs-parser] which is a pure Rust Gura 1.0.0 implementation.

Documentation - Cargo

Dependency

Add the following dependencies to your Cargo.toml:

toml [dependencies] serde = "1.0" serde_gura = "0.1.4"

If you want to use Serialize/Deserialize traits you must specify the derive feature in your Cargo.toml:

toml [dependencies] serde = { version = "1.0", features = ["derive"] } serde_gura = "0.1.4"

Using Serde Gura

API documentation is available but the general idea is:

```rust use serde::{Deserialize, Serialize}; use serde_gura::Result;

[derive(Serialize, Deserialize, PartialEq, Debug)]

struct Database { ip: String, port: Vec, connection_max: u32, enabled: bool, }

fn main() -> Result<()> { // You have some type. let database = Database { ip: "127.0.0.1".tostring(), port: vec![80, 8080], connectionmax: 1200, enabled: true, };

// Serialize it to a Gura string
let database_str = serde_gura::to_string(&database)?;
let expected = r#"

ip: "127.0.0.1" port: [80, 8080] connectionmax: 1200 enabled: true "#; asserteq!(database_str, expected.trim());

// Deserialize it back to a Rust type
let deserialized_database: Database = serde_gura::from_str(&database_str)?;
assert_eq!(database, deserialized_database);

Ok(())

} ```

License

Serde Gura is distributed under the terms of the MIT license.