UNPKG

lightningdevkit

Version:
69 lines 2.47 kB
import { TxOut } from '../structs/TxOut.mjs'; import { CommonBase } from './CommonBase.mjs'; import * as bindings from '../bindings.mjs'; /** * An enum which can either contain a crate::c_types::TxOut or not */ export class Option_TxOutZ extends CommonBase { constructor(_dummy, ptr) { super(ptr, bindings.COption_TxOutZ_free); } /* @internal */ static constr_from_ptr(ptr) { const raw_ty = bindings.LDKCOption_TxOutZ_ty_from_ptr(ptr); switch (raw_ty) { case 0: return new Option_TxOutZ_Some(ptr); case 1: return new Option_TxOutZ_None(ptr); default: throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface } } /** * Constructs a new COption_TxOutZ containing a crate::c_types::TxOut */ static constructor_some(o) { const ret = bindings.COption_TxOutZ_some(CommonBase.get_ptr_of(o)); const ret_hu_conv = Option_TxOutZ.constr_from_ptr(ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); return ret_hu_conv; } /** * Constructs a new COption_TxOutZ containing nothing */ static constructor_none() { const ret = bindings.COption_TxOutZ_none(); const ret_hu_conv = Option_TxOutZ.constr_from_ptr(ret); CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv); return ret_hu_conv; } clone_ptr() { const ret = bindings.COption_TxOutZ_clone_ptr(this.ptr); return ret; } /** * Creates a new COption_TxOutZ which has the same data as `orig` * but with all dynamically-allocated buffers duplicated in new buffers. */ clone() { const ret = bindings.COption_TxOutZ_clone(this.ptr); const ret_hu_conv = Option_TxOutZ.constr_from_ptr(ret); CommonBase.add_ref_from(ret_hu_conv, this); return ret_hu_conv; } } /** A Option_TxOutZ of type Some */ export class Option_TxOutZ_Some extends Option_TxOutZ { /* @internal */ constructor(ptr) { super(null, ptr); const some = bindings.LDKCOption_TxOutZ_Some_get_some(ptr); const some_conv = new TxOut(null, some); this.some = some_conv; } } /** A Option_TxOutZ of type None */ export class Option_TxOutZ_None extends Option_TxOutZ { /* @internal */ constructor(ptr) { super(null, ptr); } } //# sourceMappingURL=Option_TxOutZ.mjs.map