s2json-derive 1.9.1

This library supports the S2JSON 1.0 Specification
Documentation
use proc_macro::TokenStream;

mod json;
mod mvalue;
mod prim_value;

use json::generate_to_json;
use mvalue::generate_to_mvalue;
use prim_value::generate_to_value_prim;

/// Derives the `MValueCompatible` trait for a struct to convert it to a `MValue`.
#[proc_macro_derive(MValueCompatible)]
pub fn mvalue_compatible_derive(input: TokenStream) -> TokenStream {
    let ast = syn::parse(input).unwrap();
    generate_to_mvalue(&ast)
}

/// Derives the `Properties` trait for a struct to convert it to a `Properties`.
#[proc_macro_derive(Properties)]
pub fn properties_derive(input: TokenStream) -> TokenStream {
    let ast = syn::parse(input).unwrap();
    generate_to_mvalue(&ast)
}

/// Derives the `MValue` trait for a struct to convert it to a `MValue`.
#[proc_macro_derive(MValue)]
pub fn mvalue_derive(input: TokenStream) -> TokenStream {
    let ast = syn::parse(input).unwrap();
    generate_to_mvalue(&ast)
}

/// Derives the `JSONProperties` trait for a struct to convert it to a `JSONProperties`.
#[proc_macro_derive(JSONProperties)]
pub fn json_properties_derive(input: TokenStream) -> TokenStream {
    let ast = syn::parse(input).unwrap();
    generate_to_json(&ast)
}

#[proc_macro_derive(ValuePrimitive)]
pub fn primitive_value_derive(input: TokenStream) -> TokenStream {
    let ast = syn::parse(input).unwrap();
    generate_to_value_prim(&ast)
}