3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
8 export default class NodeAnnouncementInfo extends CommonBase {
9 constructor(_dummy: object, ptr: number) {
14 protected finalize() {
18 bindings.NodeAnnouncementInfo_free(this.ptr);
21 public NodeAnnouncementInfo clone() {
22 number ret = bindings.NodeAnnouncementInfo_clone(this.ptr);
23 const ret_hu_conv: NodeAnnouncementInfo = new NodeAnnouncementInfo(null, ret);
24 ret_hu_conv.ptrs_to.add(this);
28 public NodeFeatures get_features() {
29 number ret = bindings.NodeAnnouncementInfo_get_features(this.ptr);
30 const ret_hu_conv: NodeFeatures = new NodeFeatures(null, ret);
31 ret_hu_conv.ptrs_to.add(this);
35 public void set_features(NodeFeatures val) {
36 bindings.NodeAnnouncementInfo_set_features(this.ptr, val == null ? 0 : val.ptr & ~1);
37 this.ptrs_to.add(val);
38 // Due to rust's strict-ownership memory model, in some cases we need to "move"
39 // an object to pass exclusive ownership to the function being called.
40 // In most cases, we avoid this being visible in GC'd languages by cloning the object
41 // at the FFI layer, creating a new object which Rust can claim ownership of
42 // However, in some cases (eg here), there is no way to clone an object, and thus
43 // we actually have to pass full ownership to Rust.
44 // Thus, after this call, val is reset to null and is now a dummy object.
48 public number get_last_update() {
49 number ret = bindings.NodeAnnouncementInfo_get_last_update(this.ptr);
53 public void set_last_update(number val) {
54 bindings.NodeAnnouncementInfo_set_last_update(this.ptr, val);
57 public Uint8Array get_rgb() {
58 Uint8Array ret = bindings.NodeAnnouncementInfo_get_rgb(this.ptr);
62 public void set_rgb(Uint8Array val) {
63 bindings.NodeAnnouncementInfo_set_rgb(this.ptr, val);
66 public Uint8Array get_alias() {
67 Uint8Array ret = bindings.NodeAnnouncementInfo_get_alias(this.ptr);
71 public void set_alias(Uint8Array val) {
72 bindings.NodeAnnouncementInfo_set_alias(this.ptr, val);
75 public void set_addresses(NetAddress[] val) {
76 bindings.NodeAnnouncementInfo_set_addresses(this.ptr, (number[])Arrays.stream(val).map(arr_conv_12 -> arr_conv_12.ptr).toArray());
77 /* TODO 2 NetAddress */;
80 public NodeAnnouncement get_announcement_message() {
81 number ret = bindings.NodeAnnouncementInfo_get_announcement_message(this.ptr);
82 const ret_hu_conv: NodeAnnouncement = new NodeAnnouncement(null, ret);
83 ret_hu_conv.ptrs_to.add(this);
87 public void set_announcement_message(NodeAnnouncement val) {
88 bindings.NodeAnnouncementInfo_set_announcement_message(this.ptr, val == null ? 0 : val.ptr & ~1);
89 this.ptrs_to.add(val);
92 public static NodeAnnouncementInfo constructor_new(NodeFeatures features_arg, number last_update_arg, Uint8Array rgb_arg, Uint8Array alias_arg, NetAddress[] addresses_arg, NodeAnnouncement announcement_message_arg) {
93 number ret = bindings.NodeAnnouncementInfo_new(features_arg == null ? 0 : features_arg.ptr & ~1, last_update_arg, rgb_arg, alias_arg, (number[])Arrays.stream(addresses_arg).map(arr_conv_12 -> arr_conv_12.ptr).toArray(), announcement_message_arg == null ? 0 : announcement_message_arg.ptr & ~1);
94 const ret_hu_conv: NodeAnnouncementInfo = new NodeAnnouncementInfo(null, ret);
95 ret_hu_conv.ptrs_to.add(ret_hu_conv);
96 ret_hu_conv.ptrs_to.add(features_arg);
97 // Due to rust's strict-ownership memory model, in some cases we need to "move"
98 // an object to pass exclusive ownership to the function being called.
99 // In most cases, we avoid ret_hu_conv being visible in GC'd languages by cloning the object
100 // at the FFI layer, creating a new object which Rust can claim ownership of
101 // However, in some cases (eg here), there is no way to clone an object, and thus
102 // we actually have to pass full ownership to Rust.
103 // Thus, after ret_hu_conv call, features_arg is reset to null and is now a dummy object.
104 features_arg.ptr = 0;
105 /* TODO 2 NetAddress */;
106 ret_hu_conv.ptrs_to.add(announcement_message_arg);
110 public Uint8Array write() {
111 Uint8Array ret = bindings.NodeAnnouncementInfo_write(this.ptr);
115 public static Result_NodeAnnouncementInfoDecodeErrorZ constructor_read(Uint8Array ser) {
116 number ret = bindings.NodeAnnouncementInfo_read(ser);
117 Result_NodeAnnouncementInfoDecodeErrorZ ret_hu_conv = Result_NodeAnnouncementInfoDecodeErrorZ.constr_from_ptr(ret);