Hard-code dependent crate feature flags
[ldk-c-bindings] / lightning-c-bindings / src / c_types / mod.rs
index bae1c404e5c6b6d7eeaa0e81627a13b13704f122..858e227b650662169da0ccae576a01d705830225 100644 (file)
@@ -24,11 +24,10 @@ use core::convert::TryInto; // Bindings need at least rustc 1.34
 use alloc::borrow::ToOwned;
 use core::ffi::c_void;
 
-#[cfg(feature = "std")]
+#[cfg(not(feature = "no-std"))]
 pub(crate) use std::io::{self, Cursor, Read};
 #[cfg(feature = "no-std")]
 pub(crate) use core2::io::{self, Cursor, Read};
-#[cfg(feature = "no-std")]
 use alloc::{boxed::Box, vec::Vec, string::String};
 
 use core::convert::TryFrom;
@@ -292,6 +291,9 @@ impl BigEndianScalar {
 pub extern "C" fn BigEndianScalar_new(big_endian_bytes: ThirtyTwoBytes) -> BigEndianScalar {
        BigEndianScalar { big_endian_bytes: big_endian_bytes.data }
 }
+#[no_mangle]
+/// Creates a new BigEndianScalar which has the same data as `orig`
+pub extern "C" fn BigEndianScalar_clone(orig: &BigEndianScalar) -> BigEndianScalar { orig.clone() }
 
 #[repr(C)]
 #[derive(Copy, Clone)]
@@ -774,6 +776,7 @@ pub struct ThirtyTwoBytes {
        pub data: [u8; 32],
 }
 
+#[derive(Clone)]
 #[repr(C)]
 /// A 3-byte byte array.
 pub struct ThreeBytes { /** The three bytes */ pub data: [u8; 3], }
@@ -865,7 +868,7 @@ impl Str {
                };
                String::from_utf8(bytes).unwrap()
        }
-       #[cfg(feature = "std")]
+       #[cfg(not(feature = "no-std"))]
        pub(crate) fn into_pathbuf(mut self) -> std::path::PathBuf {
                std::path::PathBuf::from(self.into_string())
        }
@@ -876,7 +879,7 @@ impl Into<Str> for String {
                Str { chars: s.as_ptr(), len: s.len(), chars_is_owned: true }
        }
 }
-#[cfg(feature = "std")]
+#[cfg(not(feature = "no-std"))]
 impl Into<Str> for std::path::PathBuf {
        fn into(self) -> Str {
                self.into_os_string().into_string().expect("We expect paths to be UTF-8 valid").into()