Bindings updates
[ldk-java] / ts / structs / ErrorAction.ts
1
2 import CommonBase from './CommonBase';
3 import * as bindings from '../bindings' // TODO: figure out location
4
5 export default class ErrorAction extends CommonBase {
6         protected constructor(_dummy: object, ptr: number) { super(ptr); }
7         protected finalize() {
8                 super.finalize();
9                 if (this.ptr != 0) { bindings.ErrorAction_free(this.ptr); }
10         }
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);
15                 }
16                 if (raw_val instanceof bindings.LDKErrorAction.IgnoreError) {
17                         return new IgnoreError(this.ptr, raw_val);
18                 }
19                 if (raw_val instanceof bindings.LDKErrorAction.SendErrorMessage) {
20                         return new SendErrorMessage(this.ptr, raw_val);
21                 }
22                 throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
23         }
24
25 }
26 export class DisconnectPeer extends ErrorAction {
27         public msg: ErrorMessage;
28         private constructor(ptr: number, obj: bindings.LDKErrorAction.DisconnectPeer) {
29                 super(null, ptr);
30                 const msg: number = obj.msg;
31                 const msg_hu_conv: ErrorMessage = new ErrorMessage(null, msg);
32                 this.msg = msg_hu_conv;
33         }
34 }
35 export class IgnoreError extends ErrorAction {
36         private constructor(ptr: number, obj: bindings.LDKErrorAction.IgnoreError) {
37                 super(null, ptr);
38         }
39 }
40 export class SendErrorMessage extends ErrorAction {
41         public msg: ErrorMessage;
42         private constructor(ptr: number, obj: bindings.LDKErrorAction.SendErrorMessage) {
43                 super(null, ptr);
44                 const msg: number = obj.msg;
45                 const msg_hu_conv: ErrorMessage = new ErrorMessage(null, msg);
46                 this.msg = msg_hu_conv;
47         }
48 }