Support passing trait instance references from C to Java without clone or double...
[ldk-java] / src / main / java / org / ldk / structs / Result_NetAddressu8Z.java
index 1149eb984fe3a36a84255a1b268eb6c6c9b77dfc..7ea9ff74a299e52805a40d1bf5eb4d517219d1ec 100644 (file)
@@ -4,6 +4,7 @@ import org.ldk.impl.bindings;
 import org.ldk.enums.*;
 import org.ldk.util.*;
 import java.util.Arrays;
+import javax.annotation.Nullable;
 
 public class Result_NetAddressu8Z extends CommonBase {
        private Result_NetAddressu8Z(Object _dummy, long ptr) { super(ptr); }
@@ -27,9 +28,6 @@ public class Result_NetAddressu8Z extends CommonBase {
                        res_hu_conv.ptrs_to.add(this);
                        this.res = res_hu_conv;
                }
-               public Result_NetAddressu8Z_OK(NetAddress res) {
-                       this(null, bindings.CResult_NetAddressu8Z_ok(res.ptr));
-               }
        }
 
        public static final class Result_NetAddressu8Z_Err extends Result_NetAddressu8Z {
@@ -38,8 +36,37 @@ public class Result_NetAddressu8Z extends CommonBase {
                        super(_dummy, ptr);
                        this.err = bindings.LDKCResult_NetAddressu8Z_get_err(ptr);
                }
-               public Result_NetAddressu8Z_Err(byte err) {
-                       this(null, bindings.CResult_NetAddressu8Z_err(err));
-               }
        }
+
+       /**
+        * Creates a new CResult_NetAddressu8Z in the success state.
+        */
+       public static Result_NetAddressu8Z ok(NetAddress o) {
+               long ret = bindings.CResult_NetAddressu8Z_ok(o.ptr);
+               if (ret >= 0 && ret < 1024) { return null; }
+               Result_NetAddressu8Z ret_hu_conv = Result_NetAddressu8Z.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a new CResult_NetAddressu8Z in the error state.
+        */
+       public static Result_NetAddressu8Z err(byte e) {
+               long ret = bindings.CResult_NetAddressu8Z_err(e);
+               if (ret >= 0 && ret < 1024) { return null; }
+               Result_NetAddressu8Z ret_hu_conv = Result_NetAddressu8Z.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
+       /**
+        * Creates a new CResult_NetAddressu8Z which has the same data as `orig`
+        * but with all dynamically-allocated buffers duplicated in new buffers.
+        */
+       public Result_NetAddressu8Z clone() {
+               long ret = bindings.CResult_NetAddressu8Z_clone(this.ptr);
+               if (ret >= 0 && ret < 1024) { return null; }
+               Result_NetAddressu8Z ret_hu_conv = Result_NetAddressu8Z.constr_from_ptr(ret);
+               return ret_hu_conv;
+       }
+
 }