2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
5 export default class ErrorAction extends CommonBase {
6 protected constructor(_dummy: object, ptr: number) { super(ptr); }
9 if (this.ptr != 0) { bindings.ErrorAction_free(this.ptr); }
11 static constr_from_ptr(ptr: number): ErrorAction {
12 const raw_val: bindings.LDKErrorAction = bindings.LDKErrorAction_ref_from_ptr(ptr);
13 if (raw_val instanceof bindings.LDKErrorAction.DisconnectPeer) {
14 return new DisconnectPeer(this.ptr, raw_val);
16 if (raw_val instanceof bindings.LDKErrorAction.IgnoreError) {
17 return new IgnoreError(this.ptr, raw_val);
19 if (raw_val instanceof bindings.LDKErrorAction.SendErrorMessage) {
20 return new SendErrorMessage(this.ptr, raw_val);
22 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
26 export class DisconnectPeer extends ErrorAction {
27 public msg: ErrorMessage;
28 private constructor(ptr: number, obj: bindings.LDKErrorAction.DisconnectPeer) {
30 const msg: uint32_t = obj.msg;
31 ErrorMessage msg_hu_conv = new ErrorMessage(null, msg);
32 this.msg = msg_hu_conv;
35 export class IgnoreError extends ErrorAction {
36 private constructor(ptr: number, obj: bindings.LDKErrorAction.IgnoreError) {
40 export class SendErrorMessage extends ErrorAction {
41 public msg: ErrorMessage;
42 private constructor(ptr: number, obj: bindings.LDKErrorAction.SendErrorMessage) {
44 const msg: uint32_t = obj.msg;
45 ErrorMessage msg_hu_conv = new ErrorMessage(null, msg);
46 this.msg = msg_hu_conv;