Update auto-generated bindings
[ldk-c-bindings] / lightning-c-bindings / src / lightning_rapid_gossip_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 /// Error types that these functions can return
10
11 use alloc::str::FromStr;
12 use core::ffi::c_void;
13 use core::convert::Infallible;
14 use bitcoin::hashes::Hash;
15 use crate::c_types::*;
16 #[cfg(feature="no-std")]
17 use alloc::{vec::Vec, boxed::Box};
18
19 /// All-encompassing standard error type that processing can return
20 #[derive(Clone)]
21 #[must_use]
22 #[repr(C)]
23 pub enum GraphSyncError {
24         /// Error trying to read the update data, typically due to an erroneous data length indication
25         /// that is greater than the actual amount of data provided
26         DecodeError(crate::lightning::ln::msgs::DecodeError),
27         /// Error applying the patch to the network graph, usually the result of updates that are too
28         /// old or missing prerequisite data to the application of updates out of order
29         LightningError(crate::lightning::ln::msgs::LightningError),
30 }
31 use lightning_rapid_gossip_sync::error::GraphSyncError as GraphSyncErrorImport;
32 pub(crate) type nativeGraphSyncError = GraphSyncErrorImport;
33
34 impl GraphSyncError {
35         #[allow(unused)]
36         pub(crate) fn to_native(&self) -> nativeGraphSyncError {
37                 match self {
38                         GraphSyncError::DecodeError (ref a, ) => {
39                                 let mut a_nonref = (*a).clone();
40                                 nativeGraphSyncError::DecodeError (
41                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
42                                 )
43                         },
44                         GraphSyncError::LightningError (ref a, ) => {
45                                 let mut a_nonref = (*a).clone();
46                                 nativeGraphSyncError::LightningError (
47                                         *unsafe { Box::from_raw(a_nonref.take_inner()) },
48                                 )
49                         },
50                 }
51         }
52         #[allow(unused)]
53         pub(crate) fn into_native(self) -> nativeGraphSyncError {
54                 match self {
55                         GraphSyncError::DecodeError (mut a, ) => {
56                                 nativeGraphSyncError::DecodeError (
57                                         *unsafe { Box::from_raw(a.take_inner()) },
58                                 )
59                         },
60                         GraphSyncError::LightningError (mut a, ) => {
61                                 nativeGraphSyncError::LightningError (
62                                         *unsafe { Box::from_raw(a.take_inner()) },
63                                 )
64                         },
65                 }
66         }
67         #[allow(unused)]
68         pub(crate) fn from_native(native: &nativeGraphSyncError) -> Self {
69                 match native {
70                         nativeGraphSyncError::DecodeError (ref a, ) => {
71                                 let mut a_nonref = (*a).clone();
72                                 GraphSyncError::DecodeError (
73                                         crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
74                                 )
75                         },
76                         nativeGraphSyncError::LightningError (ref a, ) => {
77                                 let mut a_nonref = (*a).clone();
78                                 GraphSyncError::LightningError (
79                                         crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(a_nonref), is_owned: true },
80                                 )
81                         },
82                 }
83         }
84         #[allow(unused)]
85         pub(crate) fn native_into(native: nativeGraphSyncError) -> Self {
86                 match native {
87                         nativeGraphSyncError::DecodeError (mut a, ) => {
88                                 GraphSyncError::DecodeError (
89                                         crate::lightning::ln::msgs::DecodeError { inner: ObjOps::heap_alloc(a), is_owned: true },
90                                 )
91                         },
92                         nativeGraphSyncError::LightningError (mut a, ) => {
93                                 GraphSyncError::LightningError (
94                                         crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(a), is_owned: true },
95                                 )
96                         },
97                 }
98         }
99 }
100 /// Frees any resources used by the GraphSyncError
101 #[no_mangle]
102 pub extern "C" fn GraphSyncError_free(this_ptr: GraphSyncError) { }
103 /// Creates a copy of the GraphSyncError
104 #[no_mangle]
105 pub extern "C" fn GraphSyncError_clone(orig: &GraphSyncError) -> GraphSyncError {
106         orig.clone()
107 }
108 #[no_mangle]
109 /// Utility method to constructs a new DecodeError-variant GraphSyncError
110 pub extern "C" fn GraphSyncError_decode_error(a: crate::lightning::ln::msgs::DecodeError) -> GraphSyncError {
111         GraphSyncError::DecodeError(a, )
112 }
113 #[no_mangle]
114 /// Utility method to constructs a new LightningError-variant GraphSyncError
115 pub extern "C" fn GraphSyncError_lightning_error(a: crate::lightning::ln::msgs::LightningError) -> GraphSyncError {
116         GraphSyncError::LightningError(a, )
117 }