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.IgnoreAndLog) {
20 return new IgnoreAndLog(this.ptr, raw_val);
22 if (raw_val instanceof bindings.LDKErrorAction.IgnoreDuplicateGossip) {
23 return new IgnoreDuplicateGossip(this.ptr, raw_val);
25 if (raw_val instanceof bindings.LDKErrorAction.SendErrorMessage) {
26 return new SendErrorMessage(this.ptr, raw_val);
28 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
32 export class DisconnectPeer extends ErrorAction {
33 public msg: ErrorMessage;
34 private constructor(ptr: number, obj: bindings.LDKErrorAction.DisconnectPeer) {
36 const msg: number = obj.msg;
37 const msg_hu_conv: ErrorMessage = new ErrorMessage(null, msg);
38 msg_hu_conv.ptrs_to.add(this);
39 this.msg = msg_hu_conv;
42 export class IgnoreError extends ErrorAction {
43 private constructor(ptr: number, obj: bindings.LDKErrorAction.IgnoreError) {
47 export class IgnoreAndLog extends ErrorAction {
48 public ignore_and_log: Level;
49 private constructor(ptr: number, obj: bindings.LDKErrorAction.IgnoreAndLog) {
51 this.ignore_and_log = obj.ignore_and_log;
54 export class IgnoreDuplicateGossip extends ErrorAction {
55 private constructor(ptr: number, obj: bindings.LDKErrorAction.IgnoreDuplicateGossip) {
59 export class SendErrorMessage extends ErrorAction {
60 public msg: ErrorMessage;
61 private constructor(ptr: number, obj: bindings.LDKErrorAction.SendErrorMessage) {
63 const msg: number = obj.msg;
64 const msg_hu_conv: ErrorMessage = new ErrorMessage(null, msg);
65 msg_hu_conv.ptrs_to.add(this);
66 this.msg = msg_hu_conv;
69 public number clone_ptr() {
70 number ret = bindings.ErrorAction_clone_ptr(this.ptr);
74 public ErrorAction clone() {
75 number ret = bindings.ErrorAction_clone(this.ptr);
76 ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
77 ret_hu_conv.ptrs_to.add(this);
81 public static ErrorAction constructor_disconnect_peer(ErrorMessage msg) {
82 number ret = bindings.ErrorAction_disconnect_peer(msg == null ? 0 : msg.ptr & ~1);
83 ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
84 ret_hu_conv.ptrs_to.add(ret_hu_conv);
88 public static ErrorAction constructor_ignore_error() {
89 number ret = bindings.ErrorAction_ignore_error();
90 ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
91 ret_hu_conv.ptrs_to.add(ret_hu_conv);
95 public static ErrorAction constructor_ignore_and_log(Level a) {
96 number ret = bindings.ErrorAction_ignore_and_log(a);
97 ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
98 ret_hu_conv.ptrs_to.add(ret_hu_conv);
102 public static ErrorAction constructor_ignore_duplicate_gossip() {
103 number ret = bindings.ErrorAction_ignore_duplicate_gossip();
104 ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
105 ret_hu_conv.ptrs_to.add(ret_hu_conv);
109 public static ErrorAction constructor_send_error_message(ErrorMessage msg) {
110 number ret = bindings.ErrorAction_send_error_message(msg == null ? 0 : msg.ptr & ~1);
111 ErrorAction ret_hu_conv = ErrorAction.constr_from_ptr(ret);
112 ret_hu_conv.ptrs_to.add(ret_hu_conv);