SANE-rs

SANE Serialization and Deserialization for Rust


Build Status sane-rs crate sane-rs documentation

Spec: https://opensource.bloom.sh/sane

Compatible with SANE version: v1.0.0

  1. Usage
  2. Contributing
  3. License

Usage

``rust //! An example showing off the usage ofDeserializeto automatically decode //! SANE into a Ruststruct`

![deny(warnings)]

use sane; use serde::{Deserialize};

/// This is what we're going to decode into. Each field is optional, meaning /// that it doesn't have to be present in SANE.

[derive(Debug, Deserialize)]

struct Config { globalstring: Option, globalinteger: Option, server: Option, peers: Option>, }

/// Sub-structs are decoded from tables, so this will decode from the [server] /// table. /// /// Again, each field is optional, meaning they don't have to be present.

[derive(Debug, Deserialize)]

struct ServerConfig { ip: Option, port: Option, }

[derive(Debug, Deserialize)]

struct PeerConfig { ip: Option, port: Option, }

fn main() { let sanestr = r#" globalstring = "test" global_integer = 5 server = { ip = "127.0.0.1", port = 80 } peers = [ { ip = "127.0.0.1", port = 8080, }, { ip = "127.0.0.1" }, ] "#;

let decoded: Config = sane::from_str(sane_str).unwrap();
println!("{:#?}", decoded);

} ```

Contributing

Thank you for your interest in contributing! Please refer to https://opensource.bloom.sh/contributing for guidance.

License

See LICENSE.txt and https://opensource.bloom.sh/licensing

From an original work by alexcrichton: toml-rs - commit d729bf9c53fcfe8f1e5506a938b88d81526b55a4