X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Fc_types%2Fderived.rs;h=fef1837b07cc9f80a4514c3c864191d6d60bdeeb;hp=c9d57ee472888560d5a470b9ee28c8168970690a;hb=4eb8bb460e025c3d79a47b25cfff6baf068679bb;hpb=25f222f9d1efbe67389ae463fad12cbafce04156 diff --git a/lightning-c-bindings/src/c_types/derived.rs b/lightning-c-bindings/src/c_types/derived.rs index c9d57ee..fef1837 100644 --- a/lightning-c-bindings/src/c_types/derived.rs +++ b/lightning-c-bindings/src/c_types/derived.rs @@ -4090,6 +4090,97 @@ impl Clone for CResult_NonePaymentSendFailureZ { /// but with all dynamically-allocated buffers duplicated in new buffers. pub extern "C" fn CResult_NonePaymentSendFailureZ_clone(orig: &CResult_NonePaymentSendFailureZ) -> CResult_NonePaymentSendFailureZ { orig.clone() } #[repr(C)] +/// The contents of CResult_PaymentHashPaymentSendFailureZ +pub union CResult_PaymentHashPaymentSendFailureZPtr { + /// A pointer to the contents in the success state. + /// Reading from this pointer when `result_ok` is not set is undefined. + pub result: *mut crate::c_types::ThirtyTwoBytes, + /// A pointer to the contents in the error state. + /// Reading from this pointer when `result_ok` is set is undefined. + pub err: *mut crate::lightning::ln::channelmanager::PaymentSendFailure, +} +#[repr(C)] +/// A CResult_PaymentHashPaymentSendFailureZ represents the result of a fallible operation, +/// containing a crate::c_types::ThirtyTwoBytes on success and a crate::lightning::ln::channelmanager::PaymentSendFailure on failure. +/// `result_ok` indicates the overall state, and the contents are provided via `contents`. +pub struct CResult_PaymentHashPaymentSendFailureZ { + /// The contents of this CResult_PaymentHashPaymentSendFailureZ, accessible via either + /// `err` or `result` depending on the state of `result_ok`. + pub contents: CResult_PaymentHashPaymentSendFailureZPtr, + /// Whether this CResult_PaymentHashPaymentSendFailureZ represents a success state. + pub result_ok: bool, +} +#[no_mangle] +/// Creates a new CResult_PaymentHashPaymentSendFailureZ in the success state. +pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_ok(o: crate::c_types::ThirtyTwoBytes) -> CResult_PaymentHashPaymentSendFailureZ { + CResult_PaymentHashPaymentSendFailureZ { + contents: CResult_PaymentHashPaymentSendFailureZPtr { + result: Box::into_raw(Box::new(o)), + }, + result_ok: true, + } +} +#[no_mangle] +/// Creates a new CResult_PaymentHashPaymentSendFailureZ in the error state. +pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_err(e: crate::lightning::ln::channelmanager::PaymentSendFailure) -> CResult_PaymentHashPaymentSendFailureZ { + CResult_PaymentHashPaymentSendFailureZ { + contents: CResult_PaymentHashPaymentSendFailureZPtr { + err: Box::into_raw(Box::new(e)), + }, + result_ok: false, + } +} +#[no_mangle] +/// Frees any resources used by the CResult_PaymentHashPaymentSendFailureZ. +pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_free(_res: CResult_PaymentHashPaymentSendFailureZ) { } +impl Drop for CResult_PaymentHashPaymentSendFailureZ { + fn drop(&mut self) { + if self.result_ok { + if unsafe { !(self.contents.result as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.result) }; + } + } else { + if unsafe { !(self.contents.err as *mut ()).is_null() } { + let _ = unsafe { Box::from_raw(self.contents.err) }; + } + } + } +} +impl From> for CResult_PaymentHashPaymentSendFailureZ { + 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_PaymentHashPaymentSendFailureZPtr { result } + } else { + let err = unsafe { o.contents.err }; + unsafe { o.contents.err = std::ptr::null_mut(); } + CResult_PaymentHashPaymentSendFailureZPtr { err } + }; + Self { + contents, + result_ok: o.result_ok, + } + } +} +impl Clone for CResult_PaymentHashPaymentSendFailureZ { + fn clone(&self) -> Self { + if self.result_ok { + Self { result_ok: true, contents: CResult_PaymentHashPaymentSendFailureZPtr { + result: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.result }))) + } } + } else { + Self { result_ok: false, contents: CResult_PaymentHashPaymentSendFailureZPtr { + err: Box::into_raw(Box::new(::clone(unsafe { &*self.contents.err }))) + } } + } + } +} +#[no_mangle] +/// Creates a new CResult_PaymentHashPaymentSendFailureZ which has the same data as `orig` +/// but with all dynamically-allocated buffers duplicated in new buffers. +pub extern "C" fn CResult_PaymentHashPaymentSendFailureZ_clone(orig: &CResult_PaymentHashPaymentSendFailureZ) -> CResult_PaymentHashPaymentSendFailureZ { orig.clone() } +#[repr(C)] /// A dynamically-allocated array of crate::lightning::ln::msgs::NetAddresss of arbitrary size. /// This corresponds to std::vector in C++ pub struct CVec_NetAddressZ {