multihash_derive_impl/
lib.rs1extern crate proc_macro;
8
9mod multihash;
10mod utils;
11
12use proc_macro::TokenStream;
13use synstructure::macros::{parse, DeriveInput};
14use synstructure::{MacroResult, Structure};
15
16#[proc_macro_derive(Multihash, attributes(mh))]
17#[allow(non_snake_case)]
18#[deprecated(since = "0.8.1", note = "Use `MultihashDigest` derive instead.")]
19pub fn Multihash(i: TokenStream) -> TokenStream {
20 match parse::<DeriveInput>(i) {
21 Ok(p) => match Structure::try_new(&p) {
22 Ok(s) => multihash::multihash(s).into_stream(),
23 Err(e) => e.to_compile_error().into(),
24 },
25 Err(e) => e.to_compile_error().into(),
26 }
27}
28
29#[proc_macro_derive(MultihashDigest, attributes(mh))]
31#[allow(non_snake_case)]
32pub fn MultihashDigest(i: TokenStream) -> TokenStream {
33 #[allow(deprecated)]
34 Multihash(i)
35}