UNPKG

lightningdevkit

Version:
55 lines 2.02 kB
import { Address } from '../structs/Address.mjs'; import { CommonBase } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs'; /** * An enum which can either contain a crate::c_types::Address or not */ export class Option_AddressZ extends CommonBase { constructor(_dummy, ptr) { super(ptr, bindings.COption_AddressZ_free); } /* @internal */ static constr_from_ptr(ptr) { const raw_ty = bindings.LDKCOption_AddressZ_ty_from_ptr(ptr); switch (raw_ty) { case 0: return new Option_AddressZ_Some(ptr); case 1: return new Option_AddressZ_None(ptr); default: throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface } } /** * Constructs a new COption_AddressZ containing a crate::c_types::Address */ static constructor_some(o) { const ret = bindings.COption_AddressZ_some(CommonBase.get_ptr_of(o)); const ret_hu_conv = Option_AddressZ.constr_from_ptr(ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); return ret_hu_conv; } /** * Constructs a new COption_AddressZ containing nothing */ static constructor_none() { const ret = bindings.COption_AddressZ_none(); const ret_hu_conv = Option_AddressZ.constr_from_ptr(ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); return ret_hu_conv; } } /** A Option_AddressZ of type Some */ export class Option_AddressZ_Some extends Option_AddressZ { /* @internal */ constructor(ptr) { super(null, ptr); const some = bindings.LDKCOption_AddressZ_Some_get_some(ptr); const some_conv = new Address(null, some); this.some = some_conv; } } /** A Option_AddressZ of type None */ export class Option_AddressZ_None extends Option_AddressZ { /* @internal */ constructor(ptr) { super(null, ptr); } } //# sourceMappingURL=Option_AddressZ.mjs.map