X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Frouting%2Fnetwork_graph.rs;h=157dbc4225e9ab0a559bdbe2f14c2b316252ceb0;hb=c2297353b53eb11528e401fe6743381c3a5bc3b5;hp=ad4c0c3b331d52150f4eb1e9dd9edecd05f080af;hpb=4b04f3ff1e4079c62103a7013b0705ccfea2a310;p=rust-lightning diff --git a/lightning-c-bindings/src/routing/network_graph.rs b/lightning-c-bindings/src/routing/network_graph.rs index ad4c0c3b..157dbc42 100644 --- a/lightning-c-bindings/src/routing/network_graph.rs +++ b/lightning-c-bindings/src/routing/network_graph.rs @@ -42,6 +42,24 @@ impl NetworkGraph { ret } } +impl Clone for NetworkGraph { + fn clone(&self) -> Self { + Self { + inner: if self.inner.is_null() { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn NetworkGraph_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeNetworkGraph)).clone() })) as *mut c_void +} +#[no_mangle] +pub extern "C" fn NetworkGraph_clone(orig: &NetworkGraph) -> NetworkGraph { + orig.clone() +} use lightning::routing::network_graph::LockedNetworkGraph as nativeLockedNetworkGraphImport; type nativeLockedNetworkGraph = nativeLockedNetworkGraphImport<'static>; @@ -559,6 +577,24 @@ pub extern "C" fn ChannelInfo_set_announcement_message(this_ptr: &mut ChannelInf let mut local_val = if val.inner.is_null() { None } else { Some( { *unsafe { Box::from_raw(val.take_inner()) } }) }; unsafe { &mut *this_ptr.inner }.announcement_message = local_val; } +impl Clone for ChannelInfo { + fn clone(&self) -> Self { + Self { + inner: if self.inner.is_null() { std::ptr::null_mut() } else { + Box::into_raw(Box::new(unsafe { &*self.inner }.clone())) }, + is_owned: true, + } + } +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ChannelInfo_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeChannelInfo)).clone() })) as *mut c_void +} +#[no_mangle] +pub extern "C" fn ChannelInfo_clone(orig: &ChannelInfo) -> ChannelInfo { + orig.clone() +} #[no_mangle] pub extern "C" fn ChannelInfo_write(obj: &ChannelInfo) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*unsafe { &*obj }.inner })