X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FResult_BlindedHopDecodeErrorZ.java;h=2d9d60212388c2bb57bccb9d5921507157c5defd;hb=239d70ea23fdf148440dfedf9479944dc0fbf394;hp=c8991f4295b00e680b64a0d886fe06417f53e3b6;hpb=384d4ce1dd44cbd9d7d09cf6ff7818ba0c3ac29b;p=ldk-java diff --git a/src/main/java/org/ldk/structs/Result_BlindedHopDecodeErrorZ.java b/src/main/java/org/ldk/structs/Result_BlindedHopDecodeErrorZ.java index c8991f42..2d9d6021 100644 --- a/src/main/java/org/ldk/structs/Result_BlindedHopDecodeErrorZ.java +++ b/src/main/java/org/ldk/structs/Result_BlindedHopDecodeErrorZ.java @@ -36,7 +36,7 @@ public class Result_BlindedHopDecodeErrorZ extends CommonBase { private Result_BlindedHopDecodeErrorZ_Err(Object _dummy, long ptr) { super(_dummy, ptr); long err = bindings.CResult_BlindedHopDecodeErrorZ_get_err(ptr); - org.ldk.structs.DecodeError err_hu_conv = null; if (err < 0 || err > 4096) { err_hu_conv = new org.ldk.structs.DecodeError(null, err); } + org.ldk.structs.DecodeError err_hu_conv = org.ldk.structs.DecodeError.constr_from_ptr(err); if (err_hu_conv != null) { err_hu_conv.ptrs_to.add(this); }; this.err = err_hu_conv; } @@ -45,28 +45,20 @@ public class Result_BlindedHopDecodeErrorZ extends CommonBase { /** * Creates a new CResult_BlindedHopDecodeErrorZ in the success state. */ - public static Result_BlindedHopDecodeErrorZ ok(BlindedHop o) { + public static Result_BlindedHopDecodeErrorZ ok(org.ldk.structs.BlindedHop o) { long ret = bindings.CResult_BlindedHopDecodeErrorZ_ok(o == null ? 0 : o.ptr); Reference.reachabilityFence(o); if (ret >= 0 && ret <= 4096) { return null; } Result_BlindedHopDecodeErrorZ ret_hu_conv = Result_BlindedHopDecodeErrorZ.constr_from_ptr(ret); if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(o); }; - // Due to rust's strict-ownership memory model, in some cases we need to "move" - // an object to pass exclusive ownership to the function being called. - // In most cases, we avoid ret_hu_conv being visible in GC'd languages by cloning the object - // at the FFI layer, creating a new object which Rust can claim ownership of - // However, in some cases (eg here), there is no way to clone an object, and thus - // we actually have to pass full ownership to Rust. - // Thus, after ret_hu_conv call, o is reset to null and is now a dummy object. - o.ptr = 0;; return ret_hu_conv; } /** * Creates a new CResult_BlindedHopDecodeErrorZ in the error state. */ - public static Result_BlindedHopDecodeErrorZ err(DecodeError e) { - long ret = bindings.CResult_BlindedHopDecodeErrorZ_err(e == null ? 0 : e.ptr); + public static Result_BlindedHopDecodeErrorZ err(org.ldk.structs.DecodeError e) { + long ret = bindings.CResult_BlindedHopDecodeErrorZ_err(e.ptr); Reference.reachabilityFence(e); if (ret >= 0 && ret <= 4096) { return null; } Result_BlindedHopDecodeErrorZ ret_hu_conv = Result_BlindedHopDecodeErrorZ.constr_from_ptr(ret); @@ -83,4 +75,22 @@ public class Result_BlindedHopDecodeErrorZ extends CommonBase { return ret; } + long clone_ptr() { + long ret = bindings.CResult_BlindedHopDecodeErrorZ_clone_ptr(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + /** + * Creates a new CResult_BlindedHopDecodeErrorZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ + public Result_BlindedHopDecodeErrorZ clone() { + long ret = bindings.CResult_BlindedHopDecodeErrorZ_clone(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + Result_BlindedHopDecodeErrorZ ret_hu_conv = Result_BlindedHopDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + }