]> git.bitcoin.ninja Git - ldk-c-bindings/blobdiff - lightning-c-bindings/src/c_types/mod.rs
Support building dependent crates with `no-std`
[ldk-c-bindings] / lightning-c-bindings / src / c_types / mod.rs
index 98e964ff6efb5b7d20ec7fe419103ee25f98c6f0..e5449a5a934281953c977bd3ddc560e448989ef8 100644 (file)
@@ -13,9 +13,13 @@ use bitcoin::secp256k1::recovery::RecoveryId;
 use bitcoin::secp256k1::recovery::RecoverableSignature as SecpRecoverableSignature;
 use bitcoin::bech32;
 
-use std::convert::TryInto; // Bindings need at least rustc 1.34
+use core::convert::TryInto; // Bindings need at least rustc 1.34
 use core::ffi::c_void;
-use std::io::{Cursor, Read}; // TODO: We should use core2 here when we support no_std
+
+#[cfg(feature = "std")]
+pub(crate) use std::io::{self, Cursor, Read};
+#[cfg(feature = "no-std")]
+pub(crate) use core2::io::{self, Cursor, Read};
 
 #[repr(C)]
 /// A dummy struct of which an instance must never exist.
@@ -404,8 +408,8 @@ pub struct ThreeBytes { /** The three bytes */ pub data: [u8; 3], }
 pub struct FourBytes { /** The four bytes */ pub data: [u8; 4], }
 #[derive(Clone)]
 #[repr(C)]
-/// A 10-byte byte array.
-pub struct TenBytes { /** The ten bytes */ pub data: [u8; 10], }
+/// A 12-byte byte array.
+pub struct TwelveBytes { /** The twelve bytes */ pub data: [u8; 12], }
 #[derive(Clone)]
 #[repr(C)]
 /// A 16-byte byte array.
@@ -417,7 +421,7 @@ pub struct TwentyBytes { /** The twenty bytes */ pub data: [u8; 20], }
 
 pub(crate) struct VecWriter(pub Vec<u8>);
 impl lightning::util::ser::Writer for VecWriter {
-       fn write_all(&mut self, buf: &[u8]) -> Result<(), ::std::io::Error> {
+       fn write_all(&mut self, buf: &[u8]) -> Result<(), io::Error> {
                self.0.extend_from_slice(buf);
                Ok(())
        }