Merge pull request #139 from TheBlueMatt/main
[ldk-java] / c_sharp / src / org / ldk / structs / UntrustedString.cs
1 using org.ldk.impl;
2 using org.ldk.enums;
3 using org.ldk.util;
4 using System;
5
6 namespace org { namespace ldk { namespace structs {
7
8
9 /**
10  * Struct to `Display` fields in a safe way using `PrintableString`
11  */
12 public class UntrustedString : CommonBase {
13         internal UntrustedString(object _dummy, long ptr) : base(ptr) { }
14         ~UntrustedString() {
15                 if (ptr != 0) { bindings.UntrustedString_free(ptr); }
16         }
17
18         public string get_a() {
19                 string ret = bindings.UntrustedString_get_a(this.ptr);
20                 GC.KeepAlive(this);
21                 return ret;
22         }
23
24         public void set_a(string val) {
25                 bindings.UntrustedString_set_a(this.ptr, val);
26                 GC.KeepAlive(this);
27                 GC.KeepAlive(val);
28         }
29
30         /**
31          * Constructs a new UntrustedString given each field
32          */
33         public static UntrustedString of(string a_arg) {
34                 long ret = bindings.UntrustedString_new(a_arg);
35                 GC.KeepAlive(a_arg);
36                 if (ret >= 0 && ret <= 4096) { return null; }
37                 org.ldk.structs.UntrustedString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UntrustedString(null, ret); }
38                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
39                 return ret_hu_conv;
40         }
41
42         internal long clone_ptr() {
43                 long ret = bindings.UntrustedString_clone_ptr(this.ptr);
44                 GC.KeepAlive(this);
45                 return ret;
46         }
47
48         /**
49          * Creates a copy of the UntrustedString
50          */
51         public UntrustedString clone() {
52                 long ret = bindings.UntrustedString_clone(this.ptr);
53                 GC.KeepAlive(this);
54                 if (ret >= 0 && ret <= 4096) { return null; }
55                 org.ldk.structs.UntrustedString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UntrustedString(null, ret); }
56                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
57                 return ret_hu_conv;
58         }
59
60         /**
61          * Checks if two UntrustedStrings contain equal inner contents.
62          * This ignores pointers and is_owned flags and looks at the values in fields.
63          * Two objects with NULL inner values will be considered "equal" here.
64          */
65         public bool eq(org.ldk.structs.UntrustedString b) {
66                 bool ret = bindings.UntrustedString_eq(this.ptr, b == null ? 0 : b.ptr);
67                 GC.KeepAlive(this);
68                 GC.KeepAlive(b);
69                 if (this != null) { this.ptrs_to.AddLast(b); };
70                 return ret;
71         }
72
73         public override bool Equals(object o) {
74                 if (!(o is UntrustedString)) return false;
75                 return this.eq((UntrustedString)o);
76         }
77         /**
78          * Serialize the UntrustedString object into a byte array which can be read by UntrustedString_read
79          */
80         public byte[] write() {
81                 byte[] ret = bindings.UntrustedString_write(this.ptr);
82                 GC.KeepAlive(this);
83                 return ret;
84         }
85
86         /**
87          * Read a UntrustedString from a byte array, created by UntrustedString_write
88          */
89         public static Result_UntrustedStringDecodeErrorZ read(byte[] ser) {
90                 long ret = bindings.UntrustedString_read(ser);
91                 GC.KeepAlive(ser);
92                 if (ret >= 0 && ret <= 4096) { return null; }
93                 Result_UntrustedStringDecodeErrorZ ret_hu_conv = Result_UntrustedStringDecodeErrorZ.constr_from_ptr(ret);
94                 return ret_hu_conv;
95         }
96
97 }
98 } } }