tinc_derive/
lib.rs

1//! Derive Macro helpers for `tinc`
2//!
3//! ## License
4//!
5//! This project is licensed under the MIT or Apache-2.0 license.
6//! You can choose between one of them if you use this work.
7//!
8//! `SPDX-License-Identifier: MIT OR Apache-2.0`
9#![cfg_attr(all(coverage_nightly, test), feature(coverage_attribute))]
10#![cfg_attr(docsrs, feature(doc_auto_cfg))]
11#![deny(missing_docs)]
12#![deny(unsafe_code)]
13#![deny(unreachable_pub)]
14
15use proc_macro::TokenStream;
16
17mod message_tracker;
18
19/// `Tracker` is used to track field presence when doing JSON deserialization.
20/// This macro will generate the tracker for the given structure.
21/// ## Container Opts
22/// - `crate_path`: A string which is the path to the `tinc` crate, by default `::tinc`
23/// - `tagged`: Can only be used on enums to denote a tagged enum, default is false.
24/// ## Field / Variant Opts
25/// - `enum_path`: Forces the field to be treated as an enum, default is None.
26/// - `oneof`: The field should be treated as a oneof.
27#[proc_macro_derive(Tracker, attributes(tinc))]
28pub fn derive_message_tracker(input: TokenStream) -> TokenStream {
29    message_tracker::derive_message_tracker(input.into()).into()
30}