elastic-mapping-macro 0.1.0

Procedural macros for elastic-mapping - generate Elasticsearch mappings from Rust types
Documentation
use thiserror::Error;

#[derive(Debug, Error)]
pub(crate) enum GeneratorError {
    #[error("{0}")]
    Syn(#[from] syn::Error),
    #[error("{0}")]
    Darling(#[from] darling::Error),
    #[error("{0}")]
    Custom(String),
}

impl GeneratorError {
    pub(crate) fn write_errors(self) -> proc_macro2::TokenStream {
        match self {
            Self::Syn(err) => err.to_compile_error(),
            Self::Darling(err) => err.write_errors(),
            Self::Custom(msg) => {
                let msg = format!("elastic-mapping-macro error: {}", msg);
                quote::quote! {
                    compile_error!(#msg);
                }
            }
        }
    }
}