X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Fln%2Foutbound_payment.rs;h=0648ae38421d065b99081aaa232e582aef8e2127;hb=0ac4dbdb8352c898100b34f0ef8ed9cebfea7786;hp=946122edcdb031397e61f4b6826afdabcdd1edc9;hpb=3e46e1794f14640e35f09cc6da4169c152de34ce;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/lightning/ln/outbound_payment.rs b/lightning-c-bindings/src/lightning/ln/outbound_payment.rs index 946122e..0648ae3 100644 --- a/lightning-c-bindings/src/lightning/ln/outbound_payment.rs +++ b/lightning-c-bindings/src/lightning/ln/outbound_payment.rs @@ -73,7 +73,8 @@ impl Retry { } } #[allow(unused)] - pub(crate) fn from_native(native: &nativeRetry) -> Self { + pub(crate) fn from_native(native: &RetryImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeRetry) }; match native { nativeRetry::Attempts (ref a, ) => { let mut a_nonref = Clone::clone(a); @@ -113,6 +114,16 @@ pub extern "C" fn Retry_free(this_ptr: Retry) { } pub extern "C" fn Retry_clone(orig: &Retry) -> Retry { orig.clone() } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Retry_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const Retry)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn Retry_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut Retry) }; +} #[no_mangle] /// Utility method to constructs a new Attempts-variant Retry pub extern "C" fn Retry_attempts(a: u32) -> Retry { @@ -123,6 +134,9 @@ pub extern "C" fn Retry_attempts(a: u32) -> Retry { pub extern "C" fn Retry_timeout(a: u64) -> Retry { Retry::Timeout(a, ) } +/// Get a string which allows debug introspection of a Retry object +pub extern "C" fn Retry_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::outbound_payment::Retry }).into()} /// Checks if two Retrys contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] @@ -143,6 +157,10 @@ pub extern "C" fn Retry_hash(o: &Retry) -> u64 { pub extern "C" fn Retry_write(obj: &crate::lightning::ln::outbound_payment::Retry) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(&unsafe { &*obj }.to_native()) } +#[allow(unused)] +pub(crate) extern "C" fn Retry_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { + Retry_write(unsafe { &*(obj as *const Retry) }) +} #[no_mangle] /// Read a Retry from a byte array, created by Retry_write pub extern "C" fn Retry_read(ser: crate::c_types::u8slice) -> crate::c_types::derived::CResult_RetryDecodeErrorZ { @@ -196,7 +214,8 @@ impl RetryableSendFailure { } } #[allow(unused)] - pub(crate) fn from_native(native: &nativeRetryableSendFailure) -> Self { + pub(crate) fn from_native(native: &RetryableSendFailureImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeRetryableSendFailure) }; match native { nativeRetryableSendFailure::PaymentExpired => RetryableSendFailure::PaymentExpired, nativeRetryableSendFailure::RouteNotFound => RetryableSendFailure::RouteNotFound, @@ -217,6 +236,16 @@ impl RetryableSendFailure { pub extern "C" fn RetryableSendFailure_clone(orig: &RetryableSendFailure) -> RetryableSendFailure { orig.clone() } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RetryableSendFailure_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const RetryableSendFailure)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn RetryableSendFailure_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut RetryableSendFailure) }; +} #[no_mangle] /// Utility method to constructs a new PaymentExpired-variant RetryableSendFailure pub extern "C" fn RetryableSendFailure_payment_expired() -> RetryableSendFailure { @@ -229,6 +258,9 @@ pub extern "C" fn RetryableSendFailure_route_not_found() -> RetryableSendFailure /// Utility method to constructs a new DuplicatePayment-variant RetryableSendFailure pub extern "C" fn RetryableSendFailure_duplicate_payment() -> RetryableSendFailure { RetryableSendFailure::DuplicatePayment} +/// Get a string which allows debug introspection of a RetryableSendFailure object +pub extern "C" fn RetryableSendFailure_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::outbound_payment::RetryableSendFailure }).into()} /// Checks if two RetryableSendFailures contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] @@ -386,7 +418,8 @@ impl PaymentSendFailure { } } #[allow(unused)] - pub(crate) fn from_native(native: &nativePaymentSendFailure) -> Self { + pub(crate) fn from_native(native: &PaymentSendFailureImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativePaymentSendFailure) }; match native { nativePaymentSendFailure::ParameterError (ref a, ) => { let mut a_nonref = Clone::clone(a); @@ -464,6 +497,16 @@ pub extern "C" fn PaymentSendFailure_free(this_ptr: PaymentSendFailure) { } pub extern "C" fn PaymentSendFailure_clone(orig: &PaymentSendFailure) -> PaymentSendFailure { orig.clone() } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PaymentSendFailure_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const PaymentSendFailure)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn PaymentSendFailure_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut PaymentSendFailure) }; +} #[no_mangle] /// Utility method to constructs a new ParameterError-variant PaymentSendFailure pub extern "C" fn PaymentSendFailure_parameter_error(a: crate::lightning::util::errors::APIError) -> PaymentSendFailure { @@ -492,6 +535,9 @@ pub extern "C" fn PaymentSendFailure_partial_failure(results: crate::c_types::de payment_id, } } +/// Get a string which allows debug introspection of a PaymentSendFailure object +pub extern "C" fn PaymentSendFailure_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::outbound_payment::PaymentSendFailure }).into()} /// Checks if two PaymentSendFailures contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] @@ -540,7 +586,8 @@ impl ProbeSendFailure { } } #[allow(unused)] - pub(crate) fn from_native(native: &nativeProbeSendFailure) -> Self { + pub(crate) fn from_native(native: &ProbeSendFailureImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeProbeSendFailure) }; match native { nativeProbeSendFailure::RouteNotFound => ProbeSendFailure::RouteNotFound, nativeProbeSendFailure::SendingFailed (ref a, ) => { @@ -571,6 +618,16 @@ pub extern "C" fn ProbeSendFailure_free(this_ptr: ProbeSendFailure) { } pub extern "C" fn ProbeSendFailure_clone(orig: &ProbeSendFailure) -> ProbeSendFailure { orig.clone() } +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ProbeSendFailure_clone_void(this_ptr: *const c_void) -> *mut c_void { + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const ProbeSendFailure)).clone() })) as *mut c_void +} +#[allow(unused)] +/// Used only if an object of this type is returned as a trait impl by a method +pub(crate) extern "C" fn ProbeSendFailure_free_void(this_ptr: *mut c_void) { + let _ = unsafe { Box::from_raw(this_ptr as *mut ProbeSendFailure) }; +} #[no_mangle] /// Utility method to constructs a new RouteNotFound-variant ProbeSendFailure pub extern "C" fn ProbeSendFailure_route_not_found() -> ProbeSendFailure { @@ -580,6 +637,9 @@ pub extern "C" fn ProbeSendFailure_route_not_found() -> ProbeSendFailure { pub extern "C" fn ProbeSendFailure_sending_failed(a: crate::lightning::ln::outbound_payment::PaymentSendFailure) -> ProbeSendFailure { ProbeSendFailure::SendingFailed(a, ) } +/// Get a string which allows debug introspection of a ProbeSendFailure object +pub extern "C" fn ProbeSendFailure_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::outbound_payment::ProbeSendFailure }).into()} /// Checks if two ProbeSendFailures contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. #[no_mangle] @@ -722,13 +782,16 @@ impl Clone for RecipientOnionFields { #[allow(unused)] /// Used only if an object of this type is returned as a trait impl by a method pub(crate) extern "C" fn RecipientOnionFields_clone_void(this_ptr: *const c_void) -> *mut c_void { - Box::into_raw(Box::new(unsafe { (*(this_ptr as *mut nativeRecipientOnionFields)).clone() })) as *mut c_void + Box::into_raw(Box::new(unsafe { (*(this_ptr as *const nativeRecipientOnionFields)).clone() })) as *mut c_void } #[no_mangle] /// Creates a copy of the RecipientOnionFields pub extern "C" fn RecipientOnionFields_clone(orig: &RecipientOnionFields) -> RecipientOnionFields { orig.clone() } +/// Get a string which allows debug introspection of a RecipientOnionFields object +pub extern "C" fn RecipientOnionFields_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::ln::outbound_payment::RecipientOnionFields }).into()} /// Checks if two RecipientOnionFieldss contain equal inner contents. /// This ignores pointers and is_owned flags and looks at the values in fields. /// Two objects with NULL inner values will be considered "equal" here. @@ -743,7 +806,7 @@ pub extern "C" fn RecipientOnionFields_eq(a: &RecipientOnionFields, b: &Recipien pub extern "C" fn RecipientOnionFields_write(obj: &crate::lightning::ln::outbound_payment::RecipientOnionFields) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*obj }.get_native_ref()) } -#[no_mangle] +#[allow(unused)] pub(crate) extern "C" fn RecipientOnionFields_write_void(obj: *const c_void) -> crate::c_types::derived::CVec_u8Z { crate::c_types::serialize_obj(unsafe { &*(obj as *const nativeRecipientOnionFields) }) }