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
-
12
1
use proc_macro:: TokenStream ;
13
2
use quote:: { format_ident, quote} ;
14
3
use syn:: { self , parse_macro_input, DeriveInput } ;
15
4
16
5
/// 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[]}`
17
15
#[ proc_macro_derive( Json ) ]
18
16
pub fn derive_json_fn ( input : TokenStream ) -> TokenStream {
19
17
let ast = parse_macro_input ! ( input as DeriveInput ) ;
You can’t perform that action at this time.
0 commit comments