3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
8 export class CustomMessageReader extends CommonBase {
10 bindings_instance?: bindings.LDKCustomMessageReader;
12 constructor(ptr?: number, arg?: bindings.LDKCustomMessageReader) {
13 if (Number.isFinite(ptr)) {
15 this.bindings_instance = null;
17 // TODO: private constructor instantiation
18 super(bindings.LDKCustomMessageReader_new(arg));
19 this.ptrs_to.push(arg);
24 protected finalize() {
26 bindings.CustomMessageReader_free(this.ptr);
31 static new_impl(arg: CustomMessageReaderInterface): CustomMessageReader {
32 const impl_holder: LDKCustomMessageReaderHolder = new LDKCustomMessageReaderHolder();
33 let structImplementation = <bindings.LDKCustomMessageReader>{
34 // todo: in-line interface filling
35 read (message_type: number, buffer: Uint8Array): number {
36 Result_COption_TypeZDecodeErrorZ ret = arg.read(message_type, buffer);
37 result: number = ret == null ? 0 : ret.clone_ptr();
43 impl_holder.held = new CustomMessageReader (null, structImplementation);
47 export interface CustomMessageReaderInterface {
48 read(message_type: number, buffer: Uint8Array): Result_COption_TypeZDecodeErrorZ;
52 class LDKCustomMessageReaderHolder {
53 held: CustomMessageReader;
55 public Result_COption_TypeZDecodeErrorZ read(number message_type, Uint8Array buffer) {
56 number ret = bindings.CustomMessageReader_read(this.ptr, message_type, buffer);
57 Result_COption_TypeZDecodeErrorZ ret_hu_conv = Result_COption_TypeZDecodeErrorZ.constr_from_ptr(ret);