File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed
runtimes/rust/lbr-prelude-derive/src Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change 1- //! Automatically derive Json trait implementations
2- //!
3- //! Currently we only support a subset of types with an opinionated serialisation scheme. If you
4- //! need anything else than what this library provides, it is advised to hand write the
5- //! implementation.
6- //!
7- //! Supported types:
8- //! - **unit structs (newtypes)**: this will simply remove the wrapper, and serialize the wrapped value
9- //! - **structs**: serialized into a Json Object
10- //! - **enums with unnamed fields**: serialized into an object with the following schema: `{"name": string, "fields": any[]}`
11-
121use proc_macro:: TokenStream ;
132use quote:: { format_ident, quote} ;
143use syn:: { self , parse_macro_input, DeriveInput } ;
154
165/// Derive a `Json` trait implementation
6+ ///
7+ /// Currently we only support a subset of types with an opinionated serialisation scheme. If you
8+ /// need anything else than what this library provides, it is advised to hand write the
9+ /// implementation.
10+ ///
11+ /// Supported types:
12+ /// - **unit structs (newtypes)**: this will simply remove the wrapper, and serialize the wrapped value
13+ /// - **structs**: serialized into a Json Object
14+ /// - **enums with unnamed fields**: serialized into an object with the following schema: `{"name": string, "fields": any[]}`
1715#[ proc_macro_derive( Json ) ]
1816pub fn derive_json_fn ( input : TokenStream ) -> TokenStream {
1917 let ast = parse_macro_input ! ( input as DeriveInput ) ;
You can’t perform that action at this time.
0 commit comments