-/// An error that may occur when making a payment.
-#[derive(Clone)]
-#[must_use]
-#[repr(C)]
-pub enum PaymentError {
- /// An error resulting from the provided [`Bolt11Invoice`] or payment hash.
- Invoice(
- crate::c_types::Str),
- /// An error occurring when sending a payment.
- Sending(
- crate::lightning::ln::outbound_payment::RetryableSendFailure),
-}
-use lightning_invoice::payment::PaymentError as PaymentErrorImport;
-pub(crate) type nativePaymentError = PaymentErrorImport;
-
-impl PaymentError {
- #[allow(unused)]
- pub(crate) fn to_native(&self) -> nativePaymentError {
- match self {
- PaymentError::Invoice (ref a, ) => {
- let mut a_nonref = Clone::clone(a);
- nativePaymentError::Invoice (
- a_nonref.into_str(),
- )
- },
- PaymentError::Sending (ref a, ) => {
- let mut a_nonref = Clone::clone(a);
- nativePaymentError::Sending (
- a_nonref.into_native(),
- )
- },
- }
- }
- #[allow(unused)]
- pub(crate) fn into_native(self) -> nativePaymentError {
- match self {
- PaymentError::Invoice (mut a, ) => {
- nativePaymentError::Invoice (
- a.into_str(),
- )
- },
- PaymentError::Sending (mut a, ) => {
- nativePaymentError::Sending (
- a.into_native(),
- )
- },
- }
- }
- #[allow(unused)]
- pub(crate) fn from_native(native: &nativePaymentError) -> Self {
- match native {
- nativePaymentError::Invoice (ref a, ) => {
- let mut a_nonref = Clone::clone(a);
- PaymentError::Invoice (
- a_nonref.into(),
- )
- },
- nativePaymentError::Sending (ref a, ) => {
- let mut a_nonref = Clone::clone(a);
- PaymentError::Sending (
- crate::lightning::ln::outbound_payment::RetryableSendFailure::native_into(a_nonref),
- )
- },
- }
- }
- #[allow(unused)]
- pub(crate) fn native_into(native: nativePaymentError) -> Self {
- match native {
- nativePaymentError::Invoice (mut a, ) => {
- PaymentError::Invoice (
- a.into(),
- )
- },
- nativePaymentError::Sending (mut a, ) => {
- PaymentError::Sending (
- crate::lightning::ln::outbound_payment::RetryableSendFailure::native_into(a),
- )
- },
- }
- }
-}
-/// Frees any resources used by the PaymentError
-#[no_mangle]
-pub extern "C" fn PaymentError_free(this_ptr: PaymentError) { }
-/// Creates a copy of the PaymentError
-#[no_mangle]
-pub extern "C" fn PaymentError_clone(orig: &PaymentError) -> PaymentError {
- orig.clone()
-}
-#[no_mangle]
-/// Utility method to constructs a new Invoice-variant PaymentError
-pub extern "C" fn PaymentError_invoice(a: crate::c_types::Str) -> PaymentError {
- PaymentError::Invoice(a, )
-}
-#[no_mangle]
-/// Utility method to constructs a new Sending-variant PaymentError
-pub extern "C" fn PaymentError_sending(a: crate::lightning::ln::outbound_payment::RetryableSendFailure) -> PaymentError {
- PaymentError::Sending(a, )
-}
-/// Checks if two PaymentErrors contain equal inner contents.
-/// This ignores pointers and is_owned flags and looks at the values in fields.
-#[no_mangle]
-pub extern "C" fn PaymentError_eq(a: &PaymentError, b: &PaymentError) -> bool {
- if &a.to_native() == &b.to_native() { true } else { false }
-}