72ba39859dbee952f92eea6761fadb60a5bc359b
[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                 long ret = bindings.UntrustedString_get_a(this.ptr);
20                 GC.KeepAlive(this);
21                 if (ret >= 0 && ret <= 4096) { return null; }
22                 string ret_conv = InternalUtils.decodeString(ret);
23                 return ret_conv;
24         }
25
26         public void set_a(string val) {
27                 bindings.UntrustedString_set_a(this.ptr, InternalUtils.encodeString(val));
28                 GC.KeepAlive(this);
29                 GC.KeepAlive(val);
30         }
31
32         /**
33          * Constructs a new UntrustedString given each field
34          */
35         public static UntrustedString of(string a_arg) {
36                 long ret = bindings.UntrustedString_new(InternalUtils.encodeString(a_arg));
37                 GC.KeepAlive(a_arg);
38                 if (ret >= 0 && ret <= 4096) { return null; }
39                 org.ldk.structs.UntrustedString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UntrustedString(null, ret); }
40                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
41                 return ret_hu_conv;
42         }
43
44         internal long clone_ptr() {
45                 long ret = bindings.UntrustedString_clone_ptr(this.ptr);
46                 GC.KeepAlive(this);
47                 return ret;
48         }
49
50         /**
51          * Creates a copy of the UntrustedString
52          */
53         public UntrustedString clone() {
54                 long ret = bindings.UntrustedString_clone(this.ptr);
55                 GC.KeepAlive(this);
56                 if (ret >= 0 && ret <= 4096) { return null; }
57                 org.ldk.structs.UntrustedString ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.UntrustedString(null, ret); }
58                 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
59                 return ret_hu_conv;
60         }
61
62         /**
63          * Checks if two UntrustedStrings contain equal inner contents.
64          * This ignores pointers and is_owned flags and looks at the values in fields.
65          * Two objects with NULL inner values will be considered "equal" here.
66          */
67         public bool eq(org.ldk.structs.UntrustedString b) {
68                 bool ret = bindings.UntrustedString_eq(this.ptr, b == null ? 0 : b.ptr);
69                 GC.KeepAlive(this);
70                 GC.KeepAlive(b);
71                 if (this != null) { this.ptrs_to.AddLast(b); };
72                 return ret;
73         }
74
75         public override bool Equals(object o) {
76                 if (!(o is UntrustedString)) return false;
77                 return this.eq((UntrustedString)o);
78         }
79         /**
80          * Serialize the UntrustedString object into a byte array which can be read by UntrustedString_read
81          */
82         public byte[] write() {
83                 long ret = bindings.UntrustedString_write(this.ptr);
84                 GC.KeepAlive(this);
85                 if (ret >= 0 && ret <= 4096) { return null; }
86                 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);
87                 return ret_conv;
88         }
89
90         /**
91          * Read a UntrustedString from a byte array, created by UntrustedString_write
92          */
93         public static Result_UntrustedStringDecodeErrorZ read(byte[] ser) {
94                 long ret = bindings.UntrustedString_read(InternalUtils.encodeUint8Array(ser));
95                 GC.KeepAlive(ser);
96                 if (ret >= 0 && ret <= 4096) { return null; }
97                 Result_UntrustedStringDecodeErrorZ ret_hu_conv = Result_UntrustedStringDecodeErrorZ.constr_from_ptr(ret);
98                 return ret_hu_conv;
99         }
100
101 }
102 } } }