Merge pull request #70 from TheBlueMatt/main v0.0.106.1
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Wed, 13 Apr 2022 20:51:24 +0000 (20:51 +0000)
committerGitHub <noreply@github.com>
Wed, 13 Apr 2022 20:51:24 +0000 (20:51 +0000)
Expose consistent free+clone methods for `Bech32Error`

lightning-c-bindings/include/lightning.h
lightning-c-bindings/src/c_types/mod.rs

index ee15c0f2ee797b439aa36d3a5a7771285dcaafb3..cb929f6700df8a9679435b38fa70a0c7a7b60f49 100644 (file)
@@ -459,6 +459,56 @@ typedef struct LDKStr {
    bool chars_is_owned;
 } LDKStr;
 
+/**
+ * Represents an error returned from the bech32 library during validation of some bech32 data
+ */
+typedef enum LDKBech32Error_Tag {
+   /**
+    * String does not contain the separator character
+    */
+   LDKBech32Error_MissingSeparator,
+   /**
+    * The checksum does not match the rest of the data
+    */
+   LDKBech32Error_InvalidChecksum,
+   /**
+    * The data or human-readable part is too long or too short
+    */
+   LDKBech32Error_InvalidLength,
+   /**
+    * Some part of the string contains an invalid character
+    */
+   LDKBech32Error_InvalidChar,
+   /**
+    * Some part of the data has an invalid value
+    */
+   LDKBech32Error_InvalidData,
+   /**
+    * The bit conversion failed due to a padding issue
+    */
+   LDKBech32Error_InvalidPadding,
+   /**
+    * The whole string must be of one case
+    */
+   LDKBech32Error_MixedCase,
+   /**
+    * Must be last for serialization purposes
+    */
+   LDKBech32Error_Sentinel,
+} LDKBech32Error_Tag;
+
+typedef struct LDKBech32Error {
+   LDKBech32Error_Tag tag;
+   union {
+      struct {
+         uint32_t invalid_char;
+      };
+      struct {
+         uint8_t invalid_data;
+      };
+   };
+} LDKBech32Error;
+
 /**
  * A serialized transaction, in (pointer, length) form.
  *
@@ -7131,56 +7181,6 @@ typedef struct LDKCResult_PaymentIdPaymentErrorZ {
    bool result_ok;
 } LDKCResult_PaymentIdPaymentErrorZ;
 
-/**
- * Represents an error returned from the bech32 library during validation of some bech32 data
- */
-typedef enum LDKBech32Error_Tag {
-   /**
-    * String does not contain the separator character
-    */
-   LDKBech32Error_MissingSeparator,
-   /**
-    * The checksum does not match the rest of the data
-    */
-   LDKBech32Error_InvalidChecksum,
-   /**
-    * The data or human-readable part is too long or too short
-    */
-   LDKBech32Error_InvalidLength,
-   /**
-    * Some part of the string contains an invalid character
-    */
-   LDKBech32Error_InvalidChar,
-   /**
-    * Some part of the data has an invalid value
-    */
-   LDKBech32Error_InvalidData,
-   /**
-    * The bit conversion failed due to a padding issue
-    */
-   LDKBech32Error_InvalidPadding,
-   /**
-    * The whole string must be of one case
-    */
-   LDKBech32Error_MixedCase,
-   /**
-    * Must be last for serialization purposes
-    */
-   LDKBech32Error_Sentinel,
-} LDKBech32Error_Tag;
-
-typedef struct LDKBech32Error {
-   LDKBech32Error_Tag tag;
-   union {
-      struct {
-         uint32_t invalid_char;
-      };
-      struct {
-         uint8_t invalid_data;
-      };
-   };
-} LDKBech32Error;
-
 /**
  * Sub-errors which don't have specific information in them use this type.
  */
@@ -12473,6 +12473,16 @@ struct LDKStr _ldk_get_compiled_version(void);
 
 struct LDKStr _ldk_c_bindings_get_compiled_version(void);
 
+/**
+ * Creates a new Bech32Error which has the same data as `orig`
+ */
+struct LDKBech32Error Bech32Error_clone(const struct LDKBech32Error *NONNULL_PTR orig);
+
+/**
+ * Releases any memory held by the given `Bech32Error` (which is currently none)
+ */
+void Bech32Error_free(struct LDKBech32Error o);
+
 /**
  * Frees the data buffer, if data_is_owned is set and datalen > 0.
  */
index 80f04c523f421d9fd2cd64fcbb9ae0c767781999..1e88f0521e53c8ce56372278b3dcb17d3e4db3e5 100644 (file)
@@ -227,6 +227,12 @@ impl Bech32Error {
                }
        }
 }
+#[no_mangle]
+/// Creates a new Bech32Error which has the same data as `orig`
+pub extern "C" fn Bech32Error_clone(orig: &Bech32Error) -> Bech32Error { orig.clone() }
+#[no_mangle]
+/// Releases any memory held by the given `Bech32Error` (which is currently none)
+pub extern "C" fn Bech32Error_free(o: Bech32Error) { }
 
 #[repr(C)]
 #[derive(Clone, Copy, PartialEq)]