From: Matt Corallo Date: Mon, 19 Sep 2022 10:16:38 +0000 (+0000) Subject: Support mapping `Readable` `impl`s outside of the `lightning` crate X-Git-Tag: v0.0.111.0~1^2~7 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=f180d14d64d6513b9c96573075680b2b1b9b92f3;p=ldk-c-bindings Support mapping `Readable` `impl`s outside of the `lightning` crate In order to map `Readable` `impl` blocks in crates other than the `lightning` main crate we simply have to update the type references to include crate name, which we do here. --- diff --git a/c-bindings-gen/src/main.rs b/c-bindings-gen/src/main.rs index fd32a1c..9c11cf3 100644 --- a/c-bindings-gen/src/main.rs +++ b/c-bindings-gen/src/main.rs @@ -102,7 +102,7 @@ fn maybe_convert_trait_impl(w: &mut W, trait_path: &syn::Path }, "lightning::util::ser::Readable"|"lightning::util::ser::ReadableArgs"|"lightning::util::ser::MaybeReadable" => { // Create the Result syn::Type - let mut res_ty: syn::Type = parse_quote!(Result<#for_ty, ::ln::msgs::DecodeError>); + let mut res_ty: syn::Type = parse_quote!(Result<#for_ty, lightning::ln::msgs::DecodeError>); writeln!(w, "#[no_mangle]").unwrap(); writeln!(w, "/// Read a {} from a byte array, created by {}_write", for_obj, for_obj).unwrap(); @@ -151,7 +151,7 @@ fn maybe_convert_trait_impl(w: &mut W, trait_path: &syn::Path } else { unreachable!(); } } else { unreachable!(); } } else if t == "lightning::util::ser::MaybeReadable" { - res_ty = parse_quote!(Result, ::ln::msgs::DecodeError>); + res_ty = parse_quote!(Result, lightning::ln::msgs::DecodeError>); } write!(w, ") -> ").unwrap(); types.write_c_type(w, &res_ty, Some(generics), false);