serde_watson

Crates.ioserde_watson
lib.rsserde_watson
version0.1.0
sourcesrc
created_at2022-05-22 14:02:33.392899
updated_at2022-05-22 14:02:33.392899
descriptionRust implementation for Wasted but Amazing Turing-incomplete Stack-based Object Notation (WATSON)
homepage
repositoryhttps://github.com/genkami/watson-rs
max_upload_size
id591148
size104,945
Genta Kamitani (genkami)

documentation

README

serde_watson

Serde support for esoteric configuration language WATSON.

Usage

Add the following to your Cargo.toml:

[dependencies]
serde_watson = "0.1.0"

Examples

Basic Usage

use std::io;

use serde::Serialize;
use serde_watson::ser::Serializer;

#[derive(Serialize)]
struct Transaction {
    id: u64,
    from: String,
    to: String,
    amount: f64,
}

fn main() -> serde_watson::Result<()> {
    let tx = Transaction {
        id: 0xabcd1234,
        from: "Motoaki Tanigo".to_owned(),
        to: "Oozora Subaru".to_owned(),
        amount: 123.45,
    };
    let mut ser = Serializer::from_writer(io::stdout());
    tx.serialize(&mut ser)?;
    Ok(())
}

You can run the example above by running cargo run --example basic in the watson_example directory.

$ cargo run --example basic
    Finished dev [unoptimized + debuginfo] target(s) in 0.08s
     Running `target/debug/examples/basic`
~?SShkShaaakShaaaaakShaaaaaak-SShaakShaaaaakShaaaaaak-SShaakShaaaakShaaaaakShaaa
aaaaaakShaaaaaaaaaaaakShaaaaaaaaaaaaaaaakShaaaaaaaaaaaaaaaaaakShaaaaaaaaaaaaaaaa
aaakShaaaaaaaaaaaaaaaaaaaaaakShaaaaaaaaaaaaaaaaaaaaaaakShaaaaaaaaaaaaaaaaaaaaaaa
akShaaaaaaaaaaaaaaaaaaaaaaaaakShaaaaaaaaaaaaaaaaaaaaaaaaaaakShaaaaaaaaaaaaaaaaaa
aaaaaaaaaaakShaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaakig$BBubaBubbaBubbbbbaBubbbbbba!BBu
baBubbbbaBubbbbbaBubbbbbba!BBuaBubaBubbaBubbbaBubbbbbaBubbbbbba!BBuaBubbaBubbbaB
ubbbbbaBubbbbbba!?SShkShaakShaaakShaaaaaak-SShkShakShaakShaaakShaaaaakShaaaaaak-
SShaakShaaaakShaaaaakShaaaaaak-SShkShakShaakShaaakShaaaaakShaaaaaak-SShkShaaaaak
Shaaaaaak-SShkShakShaaakShaaaaakShaaaaaak-SShkShaaakShaaaaakShaaaaaak-SShaaaaak-
SShaakShaaaakShaaaaaak-SShkShaaaaakShaaaaaak-SShakShaakShaaakShaaaaakShaaaaaak-S
ShkShaaakShaaaaakShaaaaaak-SShkShakShaakShaaaaakShaaaaaak-SShkShakShaakShaaakSha
aaaakShaaaaaak-g$BBubbaBubbbbaBubbbbbaBubbbbbba!BBuaBubaBubbaBubbbaBubbbbbaBubbb
bbba!?SShkShakShaakShaaakShaaaaaak-SShkShakShaakShaaakShaaaaakShaaaaaak-SShakSha
aakShaaaakShaaaaakShaaaaaak-SShkShakShaakShaaakShaaaaakShaaaaaak-SShakShaaaakSha
aaaakShaaaaaak-SShkShaaaaakShaaaaaak-SShaaaaak-SShkShakShaaaakShaaaaaak-SShkShaa
kShaaaakShaaaaakShaaaaaak-SShakShaaaaakShaaaaaak-SShkShaaaaakShaaaaaak-SShakShaa
aakShaaaaakShaaaaaak-SShkShaakShaaaakShaaaaakShaaaaaak-g$BBuaBubbbbbaBubbbbbba!B
BuaBubbaBubbbaBubbbbbaBubbbbbba!BBuaBubaBubbaBubbbaBubbbbbaBubbbbbba!BBuaBubbaBu
bbbbaBubbbbbaBubbbbbba!BBubaBubbaBubbbaBubbbbbaBubbbbbba!BBubbaBubbbbaBubbbbbaBu
bbbbbba!BBuaBubbaBubbbaBubbbbbbaBubbbbbbbaBubbbbbbbbbbaBubbbbbbbbbbbaBubbbbbbbbb
bbbbbaBubbbbbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbbaBubbbbbbbbbbb
bbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbbbbbbbbbaBubbbbbbbbbbb
bbbbbbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbaBubbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaB
ubbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
baBubbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaB
ubbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaBu
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbaBubbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbaiM

You can verify the output using the WATSON CLI.

$ cargo run --example basic | watson decode -t json
    Finished dev [unoptimized + debuginfo] target(s) in 0.05s
     Running `target/debug/examples/basic`
{"amount":123.45,"from":"Motoaki Tanigo","id":2882343476,"to":"Oozora Subaru"}
Commit count: 173

cargo fmt