prost_convert_derive/
lib.rs

1//! This crate provides a derive macro for `TryFromProto` and `TryFromProto` traits.
2//!
3
4// TODO: change it to `warn(..)` if we go open source. Indeed `deny(..)` could break user code if it uses a
5// newer version of rust with new warnings)
6#![deny(clippy::all, clippy::cargo, missing_docs)]
7
8mod attributes;
9mod container;
10mod expand;
11mod symbol;
12use expand::expand_derive_prost_convert;
13
14use proc_macro::TokenStream;
15use syn::parse_macro_input;
16
17/// Expand the derive macro.
18#[proc_macro_derive(ProstConvert, attributes(prost_convert))]
19pub fn derive_prost_convert(input: TokenStream) -> TokenStream {
20    // Construct a representation of Rust code as a syntax tree
21    // that we can manipulate
22    let ast = parse_macro_input!(input as syn::DeriveInput);
23    expand_derive_prost_convert(ast)
24        .unwrap_or_else(syn::Error::into_compile_error)
25        .into()
26}