Crate encoding_derive_helpers[−][src]
Expand description
Helper functions for creating encoding derive crates, like
strict_encoding_derive
or lightning_encoding_derive
.
To create a derive crate, just use the following sample:
ⓘ
extern crate proc_macro;
#[macro_use]
extern crate amplify;
use encoding_derive_helpers::{decode_derive, encode_derive, TlvEncoding};
use proc_macro::TokenStream;
use syn::DeriveInput;
#[proc_macro_derive(StrictEncode, attributes(strict_encoding))]
pub fn derive_strict_encode(input: TokenStream) -> TokenStream {
let derive_input = parse_macro_input!(input as DeriveInput);
encode_derive(
"strict_encoding",
ident!(strict_encoding),
ident!(StrictEncode),
ident!(strict_encode),
ident!(strict_serialize),
derive_input,
TlvEncoding::Denied,
)
.unwrap_or_else(|e| e.to_compile_error())
.into()
}
Enums
Method for TLV encoding derivation
Functions
Performs actual derivation of the decode trait using the provided
information about trait parameters and requirements for TLV support (see
TlvEncoding
description).
Performs actual derivation of the encode trait using the provided
information about trait parameters and requirements for TLV support (see
TlvEncoding
description).