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#![deny(clippy::mod_module_files)]
15
16use proc_macro::TokenStream;
17
18mod message_tracker;
19
20/// `Tracker` is used to track field presence when doing JSON deserialization.
21/// This macro will generate the tracker for the given structure.
22/// ## Container Opts
23/// - `crate_path`: A string which is the path to the `tinc` crate, by default `::tinc`
24/// - `tagged`: Can only be used on enums to denote a tagged enum, default is false.
25/// ## Field / Variant Opts
26/// - `enum_path`: Forces the field to be treated as an enum, default is None.
27/// - `oneof`: The field should be treated as a oneof.
28#[proc_macro_derive(Tracker, attributes(tinc))]
29pub fn derive_message_tracker(input: TokenStream) -> TokenStream {
30 message_tracker::derive_message_tracker(input.into()).into()
31}