Merge pull request #61 from TheBlueMatt/main
[ldk-c-bindings] / lightning-c-bindings / src / c_types / mod.rs
index 9e928a6065922e87409de08506ddf04e26e945a4..f31d55bd1b2c7d9ec67f30552f0036d27e5b28a6 100644 (file)
@@ -20,6 +20,8 @@ use core::ffi::c_void;
 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};
 
 #[repr(C)]
 /// A dummy struct of which an instance must never exist.
@@ -65,6 +67,7 @@ impl PublicKey {
 }
 
 #[repr(C)]
+#[derive(Clone)]
 /// Represents a valid secp256k1 secret key serialized as a 32 byte array.
 pub struct SecretKey {
        /// The bytes of the secret key
@@ -192,6 +195,7 @@ pub enum IOError {
        Other,
        UnexpectedEof,
 }
+#[cfg(feature = "std")]
 impl IOError {
        pub(crate) fn from_rust(err: std::io::Error) -> Self {
                match err.kind() {
@@ -576,6 +580,9 @@ impl<T> TakePointer<*mut T> for *mut T {
 
 
 pub(crate) mod ObjOps {
+       #[cfg(feature = "no-std")]
+       use alloc::boxed::Box;
+
        #[inline]
        #[must_use = "returns new dangling pointer"]
        pub(crate) fn heap_alloc<T>(obj: T) -> *mut T {