mysql_common_derive/
lib.rs1extern crate proc_macro;
4
5use proc_macro_error2::abort;
6
7use crate::error::Error;
8type Result<T> = std::result::Result<T, crate::error::Error>;
9
10mod error;
11mod warn;
12
13mod from_row;
14mod from_value;
15
16#[proc_macro_derive(FromValue, attributes(mysql))]
18#[proc_macro_error2::proc_macro_error]
19pub fn from_value(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
20 let input: syn::DeriveInput = syn::parse(input).unwrap();
21 match from_value::impl_from_value(&input) {
22 Ok(gen) => gen.into(),
23 Err(e) => abort!(e),
24 }
25}
26
27#[proc_macro_derive(FromRow, attributes(mysql))]
29#[proc_macro_error2::proc_macro_error]
30pub fn from_row(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
31 let input: syn::DeriveInput = syn::parse(input).unwrap();
32 match from_row::impl_from_row(&input) {
33 Ok(gen) => gen.into(),
34 Err(e) => abort!(e),
35 }
36}