mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 19:37:56 +00:00
codegen: Export custom types from md to separate module
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -19,6 +19,17 @@ pub fn generate_custom_values(
|
||||
) -> TokenStream2 {
|
||||
let mut fn_names_taken = HashSet::new();
|
||||
let custom = metadata.custom();
|
||||
let custom_types = custom.iter().map(|custom| {
|
||||
let name = custom.name();
|
||||
let Ok(ty) = type_gen.resolve_type_path(custom.type_id()) else {
|
||||
return quote! {};
|
||||
};
|
||||
let ty = ty.to_token_stream(type_gen.settings());
|
||||
quote! {
|
||||
type #name = #ty;
|
||||
}
|
||||
});
|
||||
|
||||
let custom_values_fns = custom.iter().filter_map(|custom_value| {
|
||||
generate_custom_value_fn(custom_value, type_gen, crate_path, &mut fn_names_taken)
|
||||
});
|
||||
@@ -29,6 +40,10 @@ pub fn generate_custom_values(
|
||||
impl CustomValuesApi {
|
||||
#(#custom_values_fns)*
|
||||
}
|
||||
|
||||
pub mod custom_types {
|
||||
#(#custom_types)*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user