[][src]Module edn_rs::serialize

Serialization module for most possible types. Tuples are limited between (A, B) and (A, B, C, D, E, F), any other tuple needs to be implemented by the trait Serialize. This module requires #[macro_use] for structs.

Example:

#[macro_use] extern crate edn_rs;

use std::collections::{BTreeMap, BTreeSet};
use crate::edn_rs::Serialize;

fn main() {
    ser_struct!{
        #[derive(Debug)]
        struct Edn {
            map: BTreeMap<String, Vec<String>>,
            set: BTreeSet<i64>,
            tuples: (i32, bool, char),
        }
    };
    let edn = Edn {
        map: map!{"this is a key".to_string() => vec!["with".to_string(), "many".to_string(), "keys".to_string()]},
        set: set!{3i64, 4i64, 5i64},
        tuples: (3i32, true, 'd')
    };
    println!("{}",edn.serialize());
    // { :map {:this-is-a-key ["with", "many", "keys"]}, :set #{3, 4, 5}, :tuples (3, true, \d), }
}

Traits

Serialize

Trait that allows you to implement Serialization for each type of your choice. Exemple: