X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=ts%2Fstructs%2FOption_EventZ.mts;h=33db42375590bfc8233d4dbe96908d840f6d04b3;hb=4f8eade3592d704fd0d9f968aeca4810dc710a5c;hp=0ffdef06c96008fe7d2f56a62b2ac8636da018d0;hpb=bf08029c1ad5244b59902eada723b634dcade62d;p=ldk-java diff --git a/ts/structs/Option_EventZ.mts b/ts/structs/Option_EventZ.mts index 0ffdef06..33db4237 100644 --- a/ts/structs/Option_EventZ.mts +++ b/ts/structs/Option_EventZ.mts @@ -279,22 +279,26 @@ import { MultiThreadedLockableScore } from '../structs/MultiThreadedLockableScor import CommonBase from './CommonBase.mjs'; import * as bindings from '../bindings.mjs' -import * as InternalUtils from '../InternalUtils.mjs' +/** + * An enum which can either contain a crate::lightning::util::events::Event or not + */ export class Option_EventZ extends CommonBase { protected constructor(_dummy: object, ptr: number) { super(ptr, bindings.COption_EventZ_free); } /* @internal */ public static constr_from_ptr(ptr: number): Option_EventZ { - const raw_val: bindings.LDKCOption_EventZ = bindings.LDKCOption_EventZ_ref_from_ptr(ptr); - if (raw_val instanceof bindings.LDKCOption_EventZ_Some) { - return new Option_EventZ_Some(ptr, raw_val); + const raw_ty: number = bindings.LDKCOption_EventZ_ty_from_ptr(ptr); + switch (raw_ty) { + case 0: return new Option_EventZ_Some(ptr); + case 1: return new Option_EventZ_None(ptr); + default: + throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface } - if (raw_val instanceof bindings.LDKCOption_EventZ_None) { - return new Option_EventZ_None(ptr, raw_val); - } - throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface } + /** + * Constructs a new COption_EventZ containing a crate::lightning::util::events::Event + */ public static constructor_some(o: Event): Option_EventZ { const ret: number = bindings.COption_EventZ_some(CommonBase.get_ptr_of(o)); const ret_hu_conv: Option_EventZ = Option_EventZ.constr_from_ptr(ret); @@ -302,6 +306,9 @@ export class Option_EventZ extends CommonBase { return ret_hu_conv; } + /** + * Constructs a new COption_EventZ containing nothing + */ public static constructor_none(): Option_EventZ { const ret: number = bindings.COption_EventZ_none(); const ret_hu_conv: Option_EventZ = Option_EventZ.constr_from_ptr(ret); @@ -314,6 +321,10 @@ export class Option_EventZ extends CommonBase { return ret; } + /** + * Creates a new COption_EventZ which has the same data as `orig` + * but with all dynamically-allocated buffers duplicated in new buffers. + */ public clone(): Option_EventZ { const ret: number = bindings.COption_EventZ_clone(this.ptr); const ret_hu_conv: Option_EventZ = Option_EventZ.constr_from_ptr(ret); @@ -322,20 +333,22 @@ export class Option_EventZ extends CommonBase { } } +/** A Option_EventZ of type Some */ export class Option_EventZ_Some extends Option_EventZ { public some: Event; /* @internal */ - public constructor(ptr: number, obj: bindings.LDKCOption_EventZ_Some) { + public constructor(ptr: number) { super(null, ptr); - const some: number = obj.some; + const some: number = bindings.LDKCOption_EventZ_Some_get_some(ptr); const some_hu_conv: Event = Event.constr_from_ptr(some); CommonBase.add_ref_from(some_hu_conv, this); this.some = some_hu_conv; } } +/** A Option_EventZ of type None */ export class Option_EventZ_None extends Option_EventZ { /* @internal */ - public constructor(ptr: number, obj: bindings.LDKCOption_EventZ_None) { + public constructor(ptr: number) { super(null, ptr); } }