// Override the default since Records contain an fmt with a lifetime:
"lightning::util::logger::Record" => Some("*const std::os::raw::c_char"),
+ "lightning::io::Read" => Some("crate::c_types::u8slice"),
+
_ => None,
}
}
// List of traits we map (possibly during processing of other files):
"crate::util::logger::Logger" => Some(""),
+ "lightning::io::Read" => Some("&mut "),
+
_ => None,
}.map(|s| s.to_owned())
}
// List of traits we map (possibly during processing of other files):
"crate::util::logger::Logger" => Some(""),
+ "lightning::io::Read" => Some(".to_reader()"),
+
_ => None,
}.map(|s| s.to_owned())
}
// Override the default since Records contain an fmt with a lifetime:
"lightning::util::logger::Record" => Some("local_"),
+ "lightning::io::Read" => Some("crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec("),
+
_ => None,
}.map(|s| s.to_owned())
}
// Override the default since Records contain an fmt with a lifetime:
"lightning::util::logger::Record" => Some(".as_ptr()"),
+ "lightning::io::Read" => Some("))"),
+
_ => None,
}.map(|s| s.to_owned())
}
use std::convert::TryInto; // Bindings need at least rustc 1.34
+use std::io::{Cursor, Read}; // TODO: We should use core2 here when we support no_std
+
/// Integer in the range `0..32`
#[derive(PartialEq, Eq, Copy, Clone)]
#[allow(non_camel_case_types)]
if self.datalen == 0 { return &[]; }
unsafe { std::slice::from_raw_parts(self.data, self.datalen) }
}
+ pub(crate) fn to_reader<'a>(&'a self) -> Cursor<&'a [u8]> {
+ let sl = self.to_slice();
+ Cursor::new(sl)
+ }
+ pub(crate) fn from_vec(v: &derived::CVec_u8Z) -> u8slice {
+ Self::from_slice(v.as_slice())
+ }
+}
+pub(crate) fn reader_to_vec<R: Read>(r: &mut R) -> derived::CVec_u8Z {
+ let mut res = Vec::new();
+ r.read_to_end(&mut res).unwrap();
+ derived::CVec_u8Z::from(res)
}
#[repr(C)]