X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=c-bindings-gen%2Fsrc%2Ftypes.rs;h=b4b46a833a38e65bde039fabc348c68619a0fe44;hp=d15cec296571920519c78bdd1c7d0e5f939bf4b4;hb=bd76083ef39691612107fca226bad84498fc3396;hpb=76de2ac42e848418502e882a02b0b97204d35526 diff --git a/c-bindings-gen/src/types.rs b/c-bindings-gen/src/types.rs index d15cec2..b4b46a8 100644 --- a/c-bindings-gen/src/types.rs +++ b/c-bindings-gen/src/types.rs @@ -1271,6 +1271,18 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { } } + /// When printing a reference to the source crate's rust type, if we need to map it to a + /// different "real" type, it can be done so here. + /// This is useful to work around limitations in the binding type resolver, where we reference + /// a non-public `use` alias. + /// TODO: We should never need to use this! + fn real_rust_type_mapping<'equiv>(&self, thing: &'equiv str) -> &'equiv str { + match thing { + "lightning::io::Read" => "std::io::Read", + _ => thing, + } + } + // **************************** // *** Container Processing *** // **************************** @@ -1567,7 +1579,7 @@ impl<'a, 'c: 'a> TypeResolver<'a, 'c> { // If we're printing a generic argument, it needs to reference the crate, otherwise // the original crate: } else if self.maybe_resolve_path(&path, None).as_ref() == Some(&resolved) { - write!(w, "{}", resolved).unwrap(); + write!(w, "{}", self.real_rust_type_mapping(&resolved)).unwrap(); } else { write!(w, "crate::{}", resolved).unwrap(); }