X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Fc_types%2Fmod.rs;h=858e227b650662169da0ccae576a01d705830225;hb=6ad10ff1534e3a490e5fb6d00e58ab702c510c29;hp=bae1c404e5c6b6d7eeaa0e81627a13b13704f122;hpb=a8468248975b48e41bdad0939208def727110fd5;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/c_types/mod.rs b/lightning-c-bindings/src/c_types/mod.rs index bae1c40..858e227 100644 --- a/lightning-c-bindings/src/c_types/mod.rs +++ b/lightning-c-bindings/src/c_types/mod.rs @@ -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 for String { Str { chars: s.as_ptr(), len: s.len(), chars_is_owned: true } } } -#[cfg(feature = "std")] +#[cfg(not(feature = "no-std"))] impl Into for std::path::PathBuf { fn into(self) -> Str { self.into_os_string().into_string().expect("We expect paths to be UTF-8 valid").into()