X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=ts%2Fstructs%2FResult_NetworkGraphDecodeErrorZ.ts;h=38c3c2989d9cf7535a1612cd7e1dd2c4bfba3849;hb=fed2245c60159f6c074c9ed5c0f3ce273ad9841b;hp=997a3638a167df67b336813b0aa96f0cb4787099;hpb=e9c2970adecaa14b3e83e11eb160a7bcbdae20da;p=ldk-java diff --git a/ts/structs/Result_NetworkGraphDecodeErrorZ.ts b/ts/structs/Result_NetworkGraphDecodeErrorZ.ts index 997a3638..38c3c298 100644 --- a/ts/structs/Result_NetworkGraphDecodeErrorZ.ts +++ b/ts/structs/Result_NetworkGraphDecodeErrorZ.ts @@ -21,11 +21,20 @@ public class Result_NetworkGraphDecodeErrorZ extends CommonBase { super(_dummy, ptr); number res = bindings.LDKCResult_NetworkGraphDecodeErrorZ_get_ok(ptr); const res_hu_conv: NetworkGraph = new NetworkGraph(null, res); + res_hu_conv.ptrs_to.add(this); this.res = res_hu_conv; } public Result_NetworkGraphDecodeErrorZ_OK(NetworkGraph res) { this(null, bindings.CResult_NetworkGraphDecodeErrorZ_ok(res == null ? 0 : res.ptr & ~1)); this.ptrs_to.add(res); + // 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 this 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 this call, res is reset to null and is now a dummy object. + res.ptr = 0; } } @@ -35,6 +44,7 @@ public class Result_NetworkGraphDecodeErrorZ extends CommonBase { super(_dummy, ptr); number err = bindings.LDKCResult_NetworkGraphDecodeErrorZ_get_err(ptr); const err_hu_conv: DecodeError = new DecodeError(null, err); + err_hu_conv.ptrs_to.add(this); this.err = err_hu_conv; } public Result_NetworkGraphDecodeErrorZ_Err(DecodeError err) {