1 // This file is Copyright its original authors, visible in version control
2 // history and in the source files from which this was generated.
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.
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};
20 /// An error that possibly needs to be handled by the user.
24 pub enum TxSyncError {
25 /// A transaction sync failed and needs to be retried eventually.
28 use lightning_transaction_sync::error::TxSyncError as TxSyncErrorImport;
29 pub(crate) type nativeTxSyncError = TxSyncErrorImport;
33 pub(crate) fn to_native(&self) -> nativeTxSyncError {
35 TxSyncError::Failed => nativeTxSyncError::Failed,
39 pub(crate) fn into_native(self) -> nativeTxSyncError {
41 TxSyncError::Failed => nativeTxSyncError::Failed,
45 pub(crate) fn from_native(native: &TxSyncErrorImport) -> Self {
46 let native = unsafe { &*(native as *const _ as *const c_void as *const nativeTxSyncError) };
48 nativeTxSyncError::Failed => TxSyncError::Failed,
52 pub(crate) fn native_into(native: nativeTxSyncError) -> Self {
54 nativeTxSyncError::Failed => TxSyncError::Failed,
58 /// Creates a copy of the TxSyncError
60 pub extern "C" fn TxSyncError_clone(orig: &TxSyncError) -> TxSyncError {
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
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) };
74 /// Utility method to constructs a new Failed-variant TxSyncError
75 pub extern "C" fn TxSyncError_failed() -> TxSyncError {
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()}