X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=lightning-c-bindings%2Fsrc%2Fc_types%2Fderived.rs;h=d58c56b45ca851d0109b08dd96555eb8fd32c55f;hb=94bb0c9128c2635ea08ec089f79fab04880dedd0;hp=8a8b4ecab2eea406422795d622b771a5e218d683;hpb=02c21842fdf0c1918c9589dfc0039aa64f7dd249;p=rust-lightning diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index 8a8b4eca..d58c56b4 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -3286,6 +3286,86 @@ impl Clone for CResult_NoneAPIErrorZ { #[no_mangle] pub extern "C" fn CResult_NoneAPIErrorZ_clone(orig: &CResult_NoneAPIErrorZ) -> CResult_NoneAPIErrorZ { orig.clone() } #[repr(C)] +pub struct CVec_CResult_NoneAPIErrorZZ { + pub data: *mut crate::c_types::derived::CResult_NoneAPIErrorZ, + pub datalen: usize +} +impl CVec_CResult_NoneAPIErrorZZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CResult_NoneAPIErrorZ] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_CResult_NoneAPIErrorZZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +pub extern "C" fn CVec_CResult_NoneAPIErrorZZ_free(_res: CVec_CResult_NoneAPIErrorZZ) { } +impl Drop for CVec_CResult_NoneAPIErrorZZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_CResult_NoneAPIErrorZZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] +pub struct CVec_APIErrorZ { + pub data: *mut crate::util::errors::APIError, + pub datalen: usize +} +impl CVec_APIErrorZ { + #[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec { + if self.datalen == 0 { return Vec::new(); } + let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into(); + self.data = std::ptr::null_mut(); + self.datalen = 0; + ret + } + #[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::util::errors::APIError] { + unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) } + } +} +impl From> for CVec_APIErrorZ { + fn from(v: Vec) -> Self { + let datalen = v.len(); + let data = Box::into_raw(v.into_boxed_slice()); + Self { datalen, data: unsafe { (*data).as_mut_ptr() } } + } +} +#[no_mangle] +pub extern "C" fn CVec_APIErrorZ_free(_res: CVec_APIErrorZ) { } +impl Drop for CVec_APIErrorZ { + fn drop(&mut self) { + if self.datalen == 0 { return; } + unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }; + } +} +impl Clone for CVec_APIErrorZ { + fn clone(&self) -> Self { + let mut res = Vec::new(); + if self.datalen == 0 { return Self::from(res); } + res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }); + Self::from(res) + } +} +#[repr(C)] pub struct CVec_ChannelDetailsZ { pub data: *mut crate::ln::channelmanager::ChannelDetails, pub datalen: usize @@ -3772,36 +3852,36 @@ impl Clone for CResult_SignatureNoneZ { #[no_mangle] pub extern "C" fn CResult_SignatureNoneZ_clone(orig: &CResult_SignatureNoneZ) -> CResult_SignatureNoneZ { orig.clone() } #[repr(C)] -pub union CResult_ChannelKeysDecodeErrorZPtr { - pub result: *mut crate::chain::keysinterface::ChannelKeys, +pub union CResult_SignDecodeErrorZPtr { + pub result: *mut crate::chain::keysinterface::Sign, pub err: *mut crate::ln::msgs::DecodeError, } #[repr(C)] -pub struct CResult_ChannelKeysDecodeErrorZ { - pub contents: CResult_ChannelKeysDecodeErrorZPtr, +pub struct CResult_SignDecodeErrorZ { + pub contents: CResult_SignDecodeErrorZPtr, pub result_ok: bool, } #[no_mangle] -pub extern "C" fn CResult_ChannelKeysDecodeErrorZ_ok(o: crate::chain::keysinterface::ChannelKeys) -> CResult_ChannelKeysDecodeErrorZ { - CResult_ChannelKeysDecodeErrorZ { - contents: CResult_ChannelKeysDecodeErrorZPtr { +pub extern "C" fn CResult_SignDecodeErrorZ_ok(o: crate::chain::keysinterface::Sign) -> CResult_SignDecodeErrorZ { + CResult_SignDecodeErrorZ { + contents: CResult_SignDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -pub extern "C" fn CResult_ChannelKeysDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_ChannelKeysDecodeErrorZ { - CResult_ChannelKeysDecodeErrorZ { - contents: CResult_ChannelKeysDecodeErrorZPtr { +pub extern "C" fn CResult_SignDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_SignDecodeErrorZ { + CResult_SignDecodeErrorZ { + contents: CResult_SignDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -pub extern "C" fn CResult_ChannelKeysDecodeErrorZ_free(_res: CResult_ChannelKeysDecodeErrorZ) { } -impl Drop for CResult_ChannelKeysDecodeErrorZ { +pub extern "C" fn CResult_SignDecodeErrorZ_free(_res: CResult_SignDecodeErrorZ) { } +impl Drop for CResult_SignDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -3814,16 +3894,16 @@ impl Drop for CResult_ChannelKeysDecodeErrorZ { } } } -impl From> for CResult_ChannelKeysDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_SignDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_ChannelKeysDecodeErrorZPtr { result } + CResult_SignDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_ChannelKeysDecodeErrorZPtr { err } + CResult_SignDecodeErrorZPtr { err } }; Self { contents, @@ -3831,21 +3911,21 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_ChannelKeysDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_SignDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_ChannelKeysDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_SignDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -pub extern "C" fn CResult_ChannelKeysDecodeErrorZ_clone(orig: &CResult_ChannelKeysDecodeErrorZ) -> CResult_ChannelKeysDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_SignDecodeErrorZ_clone(orig: &CResult_SignDecodeErrorZ) -> CResult_SignDecodeErrorZ { orig.clone() } #[repr(C)] pub struct CVec_CVec_u8ZZ { pub data: *mut crate::c_types::derived::CVec_u8Z, @@ -3960,36 +4040,36 @@ impl Clone for CResult_CVec_CVec_u8ZZNoneZ { #[no_mangle] pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_clone(orig: &CResult_CVec_CVec_u8ZZNoneZ) -> CResult_CVec_CVec_u8ZZNoneZ { orig.clone() } #[repr(C)] -pub union CResult_InMemoryChannelKeysDecodeErrorZPtr { - pub result: *mut crate::chain::keysinterface::InMemoryChannelKeys, +pub union CResult_InMemorySignerDecodeErrorZPtr { + pub result: *mut crate::chain::keysinterface::InMemorySigner, pub err: *mut crate::ln::msgs::DecodeError, } #[repr(C)] -pub struct CResult_InMemoryChannelKeysDecodeErrorZ { - pub contents: CResult_InMemoryChannelKeysDecodeErrorZPtr, +pub struct CResult_InMemorySignerDecodeErrorZ { + pub contents: CResult_InMemorySignerDecodeErrorZPtr, pub result_ok: bool, } #[no_mangle] -pub extern "C" fn CResult_InMemoryChannelKeysDecodeErrorZ_ok(o: crate::chain::keysinterface::InMemoryChannelKeys) -> CResult_InMemoryChannelKeysDecodeErrorZ { - CResult_InMemoryChannelKeysDecodeErrorZ { - contents: CResult_InMemoryChannelKeysDecodeErrorZPtr { +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_ok(o: crate::chain::keysinterface::InMemorySigner) -> CResult_InMemorySignerDecodeErrorZ { + CResult_InMemorySignerDecodeErrorZ { + contents: CResult_InMemorySignerDecodeErrorZPtr { result: Box::into_raw(Box::new(o)), }, result_ok: true, } } #[no_mangle] -pub extern "C" fn CResult_InMemoryChannelKeysDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_InMemoryChannelKeysDecodeErrorZ { - CResult_InMemoryChannelKeysDecodeErrorZ { - contents: CResult_InMemoryChannelKeysDecodeErrorZPtr { +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_err(e: crate::ln::msgs::DecodeError) -> CResult_InMemorySignerDecodeErrorZ { + CResult_InMemorySignerDecodeErrorZ { + contents: CResult_InMemorySignerDecodeErrorZPtr { err: Box::into_raw(Box::new(e)), }, result_ok: false, } } #[no_mangle] -pub extern "C" fn CResult_InMemoryChannelKeysDecodeErrorZ_free(_res: CResult_InMemoryChannelKeysDecodeErrorZ) { } -impl Drop for CResult_InMemoryChannelKeysDecodeErrorZ { +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_free(_res: CResult_InMemorySignerDecodeErrorZ) { } +impl Drop for CResult_InMemorySignerDecodeErrorZ { fn drop(&mut self) { if self.result_ok { if unsafe { !(self.contents.result as *mut ()).is_null() } { @@ -4002,16 +4082,16 @@ impl Drop for CResult_InMemoryChannelKeysDecodeErrorZ { } } } -impl From> for CResult_InMemoryChannelKeysDecodeErrorZ { - fn from(mut o: crate::c_types::CResultTempl) -> Self { +impl From> for CResult_InMemorySignerDecodeErrorZ { + fn from(mut o: crate::c_types::CResultTempl) -> Self { let contents = if o.result_ok { let result = unsafe { o.contents.result }; unsafe { o.contents.result = std::ptr::null_mut() }; - CResult_InMemoryChannelKeysDecodeErrorZPtr { result } + CResult_InMemorySignerDecodeErrorZPtr { result } } else { let err = unsafe { o.contents.err }; unsafe { o.contents.err = std::ptr::null_mut(); } - CResult_InMemoryChannelKeysDecodeErrorZPtr { err } + CResult_InMemorySignerDecodeErrorZPtr { err } }; Self { contents, @@ -4019,21 +4099,21 @@ impl From Self { if self.result_ok { - Self { result_ok: true, contents: CResult_InMemoryChannelKeysDecodeErrorZPtr { - result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + Self { result_ok: true, contents: CResult_InMemorySignerDecodeErrorZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) } } } else { - Self { result_ok: false, contents: CResult_InMemoryChannelKeysDecodeErrorZPtr { + Self { result_ok: false, contents: CResult_InMemorySignerDecodeErrorZPtr { err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) } } } } } #[no_mangle] -pub extern "C" fn CResult_InMemoryChannelKeysDecodeErrorZ_clone(orig: &CResult_InMemoryChannelKeysDecodeErrorZ) -> CResult_InMemoryChannelKeysDecodeErrorZ { orig.clone() } +pub extern "C" fn CResult_InMemorySignerDecodeErrorZ_clone(orig: &CResult_InMemorySignerDecodeErrorZ) -> CResult_InMemorySignerDecodeErrorZ { orig.clone() } #[repr(C)] pub struct CVec_TxOutZ { pub data: *mut crate::c_types::TxOut,