1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
8 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
9 public class SocketDescriptor extends CommonBase {
10 final bindings.LDKSocketDescriptor bindings_instance;
11 SocketDescriptor(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
12 private SocketDescriptor(bindings.LDKSocketDescriptor arg) {
13 super(bindings.LDKSocketDescriptor_new(arg));
14 this.ptrs_to.add(arg);
15 this.bindings_instance = arg;
17 @Override @SuppressWarnings("deprecation")
18 protected void finalize() throws Throwable {
19 if (ptr != 0) { bindings.SocketDescriptor_free(ptr); } super.finalize();
22 public static interface SocketDescriptorInterface {
23 long send_data(byte[] data, boolean resume_read);
24 void disconnect_socket();
25 boolean eq(SocketDescriptor other_arg);
28 private static class LDKSocketDescriptorHolder { SocketDescriptor held; }
29 public static SocketDescriptor new_impl(SocketDescriptorInterface arg) {
30 final LDKSocketDescriptorHolder impl_holder = new LDKSocketDescriptorHolder();
31 impl_holder.held = new SocketDescriptor(new bindings.LDKSocketDescriptor() {
32 @Override public long send_data(byte[] data, boolean resume_read) {
33 long ret = arg.send_data(data, resume_read);
36 @Override public void disconnect_socket() {
37 arg.disconnect_socket();
39 @Override public boolean eq(long other_arg) {
40 SocketDescriptor ret_hu_conv = new SocketDescriptor(null, other_arg);
41 ret_hu_conv.ptrs_to.add(this);
42 boolean ret = arg.eq(ret_hu_conv);
45 @Override public long hash() {
46 long ret = arg.hash();
50 return impl_holder.held;
52 public long send_data(byte[] data, boolean resume_read) {
53 long ret = bindings.SocketDescriptor_send_data(this.ptr, data, resume_read);
57 public void disconnect_socket() {
58 bindings.SocketDescriptor_disconnect_socket(this.ptr);
62 long ret = bindings.SocketDescriptor_hash(this.ptr);
66 public static SocketDescriptor constructor_clone(SocketDescriptor orig) {
67 long ret = bindings.SocketDescriptor_clone(orig == null ? 0 : orig.ptr);
68 SocketDescriptor ret_hu_conv = new SocketDescriptor(null, ret);
69 ret_hu_conv.ptrs_to.add(ret_hu_conv);
70 ret_hu_conv.ptrs_to.add(orig);