Update auto-generated bindings to include ln-transaction-sync
[ldk-c-bindings] / lightning-c-bindings / src / lightning_transaction_sync / error.rs
1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
3 //
4 // This file is licensed under the license available in the LICENSE or LICENSE.md
5 // file in the root of this repository or, if no such file exists, the same
6 // license as that which applies to the original source files from which this
7 // source was automatically generated.
8
9 //! Common error types
10
11 use alloc::str::FromStr;
12 use alloc::string::String;
13 use core::ffi::c_void;
14 use core::convert::Infallible;
15 use bitcoin::hashes::Hash;
16 use crate::c_types::*;
17 #[cfg(feature="no-std")]
18 use alloc::{vec::Vec, boxed::Box};
19
20 /// An error that possibly needs to be handled by the user.
21 #[derive(Clone)]
22 #[must_use]
23 #[repr(C)]
24 pub enum TxSyncError {
25         /// A transaction sync failed and needs to be retried eventually.
26         Failed,
27 }
28 use lightning_transaction_sync::error::TxSyncError as TxSyncErrorImport;
29 pub(crate) type nativeTxSyncError = TxSyncErrorImport;
30
31 impl TxSyncError {
32         #[allow(unused)]
33         pub(crate) fn to_native(&self) -> nativeTxSyncError {
34                 match self {
35                         TxSyncError::Failed => nativeTxSyncError::Failed,
36                 }
37         }
38         #[allow(unused)]
39         pub(crate) fn into_native(self) -> nativeTxSyncError {
40                 match self {
41                         TxSyncError::Failed => nativeTxSyncError::Failed,
42                 }
43         }
44         #[allow(unused)]
45         pub(crate) fn from_native(native: &TxSyncErrorImport) -> Self {
46                 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeTxSyncError) };
47                 match native {
48                         nativeTxSyncError::Failed => TxSyncError::Failed,
49                 }
50         }
51         #[allow(unused)]
52         pub(crate) fn native_into(native: nativeTxSyncError) -> Self {
53                 match native {
54                         nativeTxSyncError::Failed => TxSyncError::Failed,
55                 }
56         }
57 }
58 /// Creates a copy of the TxSyncError
59 #[no_mangle]
60 pub extern "C" fn TxSyncError_clone(orig: &TxSyncError) -> TxSyncError {
61         orig.clone()
62 }
63 #[allow(unused)]
64 /// Used only if an object of this type is returned as a trait impl by a method
65 pub(crate) extern "C" fn TxSyncError_clone_void(this_ptr: *const c_void) -> *mut c_void {
66         Box::into_raw(Box::new(unsafe { (*(this_ptr as *const TxSyncError)).clone() })) as *mut c_void
67 }
68 #[allow(unused)]
69 /// Used only if an object of this type is returned as a trait impl by a method
70 pub(crate) extern "C" fn TxSyncError_free_void(this_ptr: *mut c_void) {
71         let _ = unsafe { Box::from_raw(this_ptr as *mut TxSyncError) };
72 }
73 #[no_mangle]
74 /// Utility method to constructs a new Failed-variant TxSyncError
75 pub extern "C" fn TxSyncError_failed() -> TxSyncError {
76         TxSyncError::Failed}
77 /// Get a string which allows debug introspection of a TxSyncError object
78 pub extern "C" fn TxSyncError_debug_str_void(o: *const c_void) -> Str {
79         alloc::format!("{:?}", unsafe { o as *const crate::lightning_transaction_sync::error::TxSyncError }).into()}