react-native-nitro-dgram 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/android/CMakeLists.txt +24 -0
  2. package/android/OnLoad.cpp +6 -0
  3. package/android/build.gradle +64 -0
  4. package/android/libs/arm64-v8a/librust_c_udp.so +0 -0
  5. package/android/libs/armeabi-v7a/librust_c_udp.so +0 -0
  6. package/android/libs/x86/librust_c_udp.so +0 -0
  7. package/android/libs/x86_64/librust_c_udp.so +0 -0
  8. package/android/src/main/java/com/margelo/nitro/udp/NitroUdpPackage.java +25 -0
  9. package/cpp/HybridUdpDriver.cpp +21 -0
  10. package/cpp/HybridUdpDriver.hpp +18 -0
  11. package/cpp/HybridUdpSocketDriver.cpp +252 -0
  12. package/cpp/HybridUdpSocketDriver.hpp +88 -0
  13. package/cpp/UdpBindings.hpp +83 -0
  14. package/cpp/UdpManager.hpp +108 -0
  15. package/ios/Frameworks/RustCUdp.xcframework/Info.plist +44 -0
  16. package/ios/Frameworks/RustCUdp.xcframework/ios-arm64/RustCUdp.framework/Info.plist +20 -0
  17. package/ios/Frameworks/RustCUdp.xcframework/ios-arm64/RustCUdp.framework/RustCUdp +0 -0
  18. package/ios/Frameworks/RustCUdp.xcframework/ios-arm64_x86_64-simulator/RustCUdp.framework/Info.plist +20 -0
  19. package/ios/Frameworks/RustCUdp.xcframework/ios-arm64_x86_64-simulator/RustCUdp.framework/RustCUdp +0 -0
  20. package/lib/Driver.d.ts +2 -0
  21. package/lib/Driver.js +6 -0
  22. package/lib/Driver.js.map +1 -0
  23. package/lib/Udp.nitro.d.ts +54 -0
  24. package/lib/Udp.nitro.js +3 -0
  25. package/lib/Udp.nitro.js.map +1 -0
  26. package/lib/index.d.ts +82 -0
  27. package/lib/index.js +375 -0
  28. package/lib/index.js.map +1 -0
  29. package/nitrogen/generated/.gitattributes +1 -0
  30. package/nitrogen/generated/android/RustCUdp+autolinking.cmake +84 -0
  31. package/nitrogen/generated/android/RustCUdp+autolinking.gradle +27 -0
  32. package/nitrogen/generated/android/RustCUdpOnLoad.cpp +53 -0
  33. package/nitrogen/generated/android/RustCUdpOnLoad.hpp +25 -0
  34. package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
  35. package/nitrogen/generated/android/c++/JFunc_void_std__shared_ptr_ArrayBuffer__std__string_double.hpp +78 -0
  36. package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
  37. package/nitrogen/generated/android/c++/JHybridUdpDriverSpec.cpp +57 -0
  38. package/nitrogen/generated/android/c++/JHybridUdpDriverSpec.hpp +65 -0
  39. package/nitrogen/generated/android/c++/JHybridUdpSocketDriverSpec.cpp +261 -0
  40. package/nitrogen/generated/android/c++/JHybridUdpSocketDriverSpec.hpp +97 -0
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/udp/Func_void.kt +80 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/udp/Func_void_std__shared_ptr_ArrayBuffer__std__string_double.kt +80 -0
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/udp/Func_void_std__string.kt +80 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/udp/HybridUdpDriverSpec.kt +57 -0
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/udp/HybridUdpSocketDriverSpec.kt +212 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/udp/RustCUdpOnLoad.kt +35 -0
  47. package/nitrogen/generated/ios/RustCUdp+autolinking.rb +60 -0
  48. package/nitrogen/generated/ios/RustCUdp-Swift-Cxx-Bridge.cpp +74 -0
  49. package/nitrogen/generated/ios/RustCUdp-Swift-Cxx-Bridge.hpp +195 -0
  50. package/nitrogen/generated/ios/RustCUdp-Swift-Cxx-Umbrella.hpp +53 -0
  51. package/nitrogen/generated/ios/RustCUdpAutolinking.mm +35 -0
  52. package/nitrogen/generated/ios/RustCUdpAutolinking.swift +12 -0
  53. package/nitrogen/generated/ios/c++/HybridUdpDriverSpecSwift.cpp +11 -0
  54. package/nitrogen/generated/ios/c++/HybridUdpDriverSpecSwift.hpp +80 -0
  55. package/nitrogen/generated/ios/c++/HybridUdpSocketDriverSpecSwift.cpp +11 -0
  56. package/nitrogen/generated/ios/c++/HybridUdpSocketDriverSpecSwift.hpp +302 -0
  57. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  58. package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_ArrayBuffer__std__string_double.swift +47 -0
  59. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +47 -0
  60. package/nitrogen/generated/ios/swift/HybridUdpDriverSpec.swift +56 -0
  61. package/nitrogen/generated/ios/swift/HybridUdpDriverSpec_cxx.swift +141 -0
  62. package/nitrogen/generated/ios/swift/HybridUdpSocketDriverSpec.swift +84 -0
  63. package/nitrogen/generated/ios/swift/HybridUdpSocketDriverSpec_cxx.swift +527 -0
  64. package/nitrogen/generated/shared/c++/HybridNitroBufferSpec.cpp +32 -0
  65. package/nitrogen/generated/shared/c++/HybridNitroBufferSpec.hpp +74 -0
  66. package/nitrogen/generated/shared/c++/HybridUdpDriverSpec.cpp +21 -0
  67. package/nitrogen/generated/shared/c++/HybridUdpDriverSpec.hpp +66 -0
  68. package/nitrogen/generated/shared/c++/HybridUdpSocketDriverSpec.cpp +54 -0
  69. package/nitrogen/generated/shared/c++/HybridUdpSocketDriverSpec.hpp +98 -0
  70. package/package.json +59 -0
  71. package/react-native-nitro-dgram.podspec +45 -0
  72. package/src/Driver.ts +4 -0
  73. package/src/Udp.nitro.ts +55 -0
  74. package/src/index.ts +414 -0
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// Func_void.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.udp
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import dalvik.annotation.optimization.FastNative
14
+
15
+
16
+ /**
17
+ * Represents the JavaScript callback `() => void`.
18
+ * This can be either implemented in C++ (in which case it might be a callback coming from JS),
19
+ * or in Kotlin/Java (in which case it is a native callback).
20
+ */
21
+ @DoNotStrip
22
+ @Keep
23
+ @Suppress("ClassName", "RedundantUnitReturnType")
24
+ fun interface Func_void: () -> Unit {
25
+ /**
26
+ * Call the given JS callback.
27
+ * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
28
+ */
29
+ @DoNotStrip
30
+ @Keep
31
+ override fun invoke(): Unit
32
+ }
33
+
34
+ /**
35
+ * Represents the JavaScript callback `() => void`.
36
+ * This is implemented in C++, via a `std::function<...>`.
37
+ * The callback might be coming from JS.
38
+ */
39
+ @DoNotStrip
40
+ @Keep
41
+ @Suppress(
42
+ "KotlinJniMissingFunction", "unused",
43
+ "RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
44
+ "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
45
+ )
46
+ class Func_void_cxx: Func_void {
47
+ @DoNotStrip
48
+ @Keep
49
+ private val mHybridData: HybridData
50
+
51
+ @DoNotStrip
52
+ @Keep
53
+ private constructor(hybridData: HybridData) {
54
+ mHybridData = hybridData
55
+ }
56
+
57
+ @DoNotStrip
58
+ @Keep
59
+ override fun invoke(): Unit
60
+ = invoke_cxx()
61
+
62
+ @FastNative
63
+ private external fun invoke_cxx(): Unit
64
+ }
65
+
66
+ /**
67
+ * Represents the JavaScript callback `() => void`.
68
+ * This is implemented in Java/Kotlin, via a `() -> Unit`.
69
+ * The callback is always coming from native.
70
+ */
71
+ @DoNotStrip
72
+ @Keep
73
+ @Suppress("ClassName", "RedundantUnitReturnType", "unused")
74
+ class Func_void_java(private val function: () -> Unit): Func_void {
75
+ @DoNotStrip
76
+ @Keep
77
+ override fun invoke(): Unit {
78
+ return this.function()
79
+ }
80
+ }
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// Func_void_std__shared_ptr_ArrayBuffer__std__string_double.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.udp
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import dalvik.annotation.optimization.FastNative
14
+ import com.margelo.nitro.core.ArrayBuffer
15
+
16
+ /**
17
+ * Represents the JavaScript callback `(data: array-buffer, address: string, port: number) => void`.
18
+ * This can be either implemented in C++ (in which case it might be a callback coming from JS),
19
+ * or in Kotlin/Java (in which case it is a native callback).
20
+ */
21
+ @DoNotStrip
22
+ @Keep
23
+ @Suppress("ClassName", "RedundantUnitReturnType")
24
+ fun interface Func_void_std__shared_ptr_ArrayBuffer__std__string_double: (ArrayBuffer, String, Double) -> Unit {
25
+ /**
26
+ * Call the given JS callback.
27
+ * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
28
+ */
29
+ @DoNotStrip
30
+ @Keep
31
+ override fun invoke(data: ArrayBuffer, address: String, port: Double): Unit
32
+ }
33
+
34
+ /**
35
+ * Represents the JavaScript callback `(data: array-buffer, address: string, port: number) => void`.
36
+ * This is implemented in C++, via a `std::function<...>`.
37
+ * The callback might be coming from JS.
38
+ */
39
+ @DoNotStrip
40
+ @Keep
41
+ @Suppress(
42
+ "KotlinJniMissingFunction", "unused",
43
+ "RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
44
+ "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
45
+ )
46
+ class Func_void_std__shared_ptr_ArrayBuffer__std__string_double_cxx: Func_void_std__shared_ptr_ArrayBuffer__std__string_double {
47
+ @DoNotStrip
48
+ @Keep
49
+ private val mHybridData: HybridData
50
+
51
+ @DoNotStrip
52
+ @Keep
53
+ private constructor(hybridData: HybridData) {
54
+ mHybridData = hybridData
55
+ }
56
+
57
+ @DoNotStrip
58
+ @Keep
59
+ override fun invoke(data: ArrayBuffer, address: String, port: Double): Unit
60
+ = invoke_cxx(data,address,port)
61
+
62
+ @FastNative
63
+ private external fun invoke_cxx(data: ArrayBuffer, address: String, port: Double): Unit
64
+ }
65
+
66
+ /**
67
+ * Represents the JavaScript callback `(data: array-buffer, address: string, port: number) => void`.
68
+ * This is implemented in Java/Kotlin, via a `(ArrayBuffer, String, Double) -> Unit`.
69
+ * The callback is always coming from native.
70
+ */
71
+ @DoNotStrip
72
+ @Keep
73
+ @Suppress("ClassName", "RedundantUnitReturnType", "unused")
74
+ class Func_void_std__shared_ptr_ArrayBuffer__std__string_double_java(private val function: (ArrayBuffer, String, Double) -> Unit): Func_void_std__shared_ptr_ArrayBuffer__std__string_double {
75
+ @DoNotStrip
76
+ @Keep
77
+ override fun invoke(data: ArrayBuffer, address: String, port: Double): Unit {
78
+ return this.function(data, address, port)
79
+ }
80
+ }
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// Func_void_std__string.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.udp
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import dalvik.annotation.optimization.FastNative
14
+
15
+
16
+ /**
17
+ * Represents the JavaScript callback `(error: string) => void`.
18
+ * This can be either implemented in C++ (in which case it might be a callback coming from JS),
19
+ * or in Kotlin/Java (in which case it is a native callback).
20
+ */
21
+ @DoNotStrip
22
+ @Keep
23
+ @Suppress("ClassName", "RedundantUnitReturnType")
24
+ fun interface Func_void_std__string: (String) -> Unit {
25
+ /**
26
+ * Call the given JS callback.
27
+ * @throws Throwable if the JS function itself throws an error, or if the JS function/runtime has already been deleted.
28
+ */
29
+ @DoNotStrip
30
+ @Keep
31
+ override fun invoke(error: String): Unit
32
+ }
33
+
34
+ /**
35
+ * Represents the JavaScript callback `(error: string) => void`.
36
+ * This is implemented in C++, via a `std::function<...>`.
37
+ * The callback might be coming from JS.
38
+ */
39
+ @DoNotStrip
40
+ @Keep
41
+ @Suppress(
42
+ "KotlinJniMissingFunction", "unused",
43
+ "RedundantSuppression", "RedundantUnitReturnType", "FunctionName",
44
+ "ConvertSecondaryConstructorToPrimary", "ClassName", "LocalVariableName",
45
+ )
46
+ class Func_void_std__string_cxx: Func_void_std__string {
47
+ @DoNotStrip
48
+ @Keep
49
+ private val mHybridData: HybridData
50
+
51
+ @DoNotStrip
52
+ @Keep
53
+ private constructor(hybridData: HybridData) {
54
+ mHybridData = hybridData
55
+ }
56
+
57
+ @DoNotStrip
58
+ @Keep
59
+ override fun invoke(error: String): Unit
60
+ = invoke_cxx(error)
61
+
62
+ @FastNative
63
+ private external fun invoke_cxx(error: String): Unit
64
+ }
65
+
66
+ /**
67
+ * Represents the JavaScript callback `(error: string) => void`.
68
+ * This is implemented in Java/Kotlin, via a `(String) -> Unit`.
69
+ * The callback is always coming from native.
70
+ */
71
+ @DoNotStrip
72
+ @Keep
73
+ @Suppress("ClassName", "RedundantUnitReturnType", "unused")
74
+ class Func_void_std__string_java(private val function: (String) -> Unit): Func_void_std__string {
75
+ @DoNotStrip
76
+ @Keep
77
+ override fun invoke(error: String): Unit {
78
+ return this.function(error)
79
+ }
80
+ }
@@ -0,0 +1,57 @@
1
+ ///
2
+ /// HybridUdpDriverSpec.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.udp
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import com.margelo.nitro.core.HybridObject
14
+
15
+ /**
16
+ * A Kotlin class representing the UdpDriver HybridObject.
17
+ * Implement this abstract class to create Kotlin-based instances of UdpDriver.
18
+ */
19
+ @DoNotStrip
20
+ @Keep
21
+ @Suppress(
22
+ "KotlinJniMissingFunction", "unused",
23
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
24
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
25
+ )
26
+ abstract class HybridUdpDriverSpec: HybridObject() {
27
+ @DoNotStrip
28
+ private var mHybridData: HybridData = initHybrid()
29
+
30
+ init {
31
+ super.updateNative(mHybridData)
32
+ }
33
+
34
+ override fun updateNative(hybridData: HybridData) {
35
+ mHybridData = hybridData
36
+ super.updateNative(hybridData)
37
+ }
38
+
39
+ // Default implementation of `HybridObject.toString()`
40
+ override fun toString(): String {
41
+ return "[HybridObject UdpDriver]"
42
+ }
43
+
44
+ // Properties
45
+
46
+
47
+ // Methods
48
+ @DoNotStrip
49
+ @Keep
50
+ abstract fun createSocket(id: String?): HybridUdpSocketDriverSpec
51
+
52
+ private external fun initHybrid(): HybridData
53
+
54
+ companion object {
55
+ protected const val TAG = "HybridUdpDriverSpec"
56
+ }
57
+ }
@@ -0,0 +1,212 @@
1
+ ///
2
+ /// HybridUdpSocketDriverSpec.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.udp
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.jni.HybridData
12
+ import com.facebook.proguard.annotations.DoNotStrip
13
+ import com.margelo.nitro.core.ArrayBuffer
14
+ import com.margelo.nitro.core.HybridObject
15
+
16
+ /**
17
+ * A Kotlin class representing the UdpSocketDriver HybridObject.
18
+ * Implement this abstract class to create Kotlin-based instances of UdpSocketDriver.
19
+ */
20
+ @DoNotStrip
21
+ @Keep
22
+ @Suppress(
23
+ "KotlinJniMissingFunction", "unused",
24
+ "RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
25
+ "LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
26
+ )
27
+ abstract class HybridUdpSocketDriverSpec: HybridObject() {
28
+ @DoNotStrip
29
+ private var mHybridData: HybridData = initHybrid()
30
+
31
+ init {
32
+ super.updateNative(mHybridData)
33
+ }
34
+
35
+ override fun updateNative(hybridData: HybridData) {
36
+ mHybridData = hybridData
37
+ super.updateNative(hybridData)
38
+ }
39
+
40
+ // Default implementation of `HybridObject.toString()`
41
+ override fun toString(): String {
42
+ return "[HybridObject UdpSocketDriver]"
43
+ }
44
+
45
+ // Properties
46
+ @get:DoNotStrip
47
+ @get:Keep
48
+ abstract val id: Double
49
+
50
+ abstract var onMessage: (data: ArrayBuffer, address: String, port: Double) -> Unit
51
+
52
+ private var onMessage_cxx: Func_void_std__shared_ptr_ArrayBuffer__std__string_double
53
+ @Keep
54
+ @DoNotStrip
55
+ get() {
56
+ return Func_void_std__shared_ptr_ArrayBuffer__std__string_double_java(onMessage)
57
+ }
58
+ @Keep
59
+ @DoNotStrip
60
+ set(value) {
61
+ onMessage = value
62
+ }
63
+
64
+ abstract var onConnect: () -> Unit
65
+
66
+ private var onConnect_cxx: Func_void
67
+ @Keep
68
+ @DoNotStrip
69
+ get() {
70
+ return Func_void_java(onConnect)
71
+ }
72
+ @Keep
73
+ @DoNotStrip
74
+ set(value) {
75
+ onConnect = value
76
+ }
77
+
78
+ abstract var onError: (error: String) -> Unit
79
+
80
+ private var onError_cxx: Func_void_std__string
81
+ @Keep
82
+ @DoNotStrip
83
+ get() {
84
+ return Func_void_std__string_java(onError)
85
+ }
86
+ @Keep
87
+ @DoNotStrip
88
+ set(value) {
89
+ onError = value
90
+ }
91
+
92
+ abstract var onClose: () -> Unit
93
+
94
+ private var onClose_cxx: Func_void
95
+ @Keep
96
+ @DoNotStrip
97
+ get() {
98
+ return Func_void_java(onClose)
99
+ }
100
+ @Keep
101
+ @DoNotStrip
102
+ set(value) {
103
+ onClose = value
104
+ }
105
+
106
+ // Methods
107
+ @DoNotStrip
108
+ @Keep
109
+ abstract fun bind(port: Double, address: String, ipv6Only: Boolean): Double
110
+
111
+ @DoNotStrip
112
+ @Keep
113
+ abstract fun connect(port: Double, address: String): Double
114
+
115
+ @DoNotStrip
116
+ @Keep
117
+ abstract fun disconnect(): Double
118
+
119
+ @DoNotStrip
120
+ @Keep
121
+ abstract fun send(data: ArrayBuffer, port: Double, address: String): Double
122
+
123
+ @DoNotStrip
124
+ @Keep
125
+ abstract fun sendMultiple(data: Array<ArrayBuffer>, port: Double, address: String): Double
126
+
127
+ @DoNotStrip
128
+ @Keep
129
+ abstract fun close(): Unit
130
+
131
+ @DoNotStrip
132
+ @Keep
133
+ abstract fun setBroadcast(flag: Boolean): Double
134
+
135
+ @DoNotStrip
136
+ @Keep
137
+ abstract fun setTTL(ttl: Double): Double
138
+
139
+ @DoNotStrip
140
+ @Keep
141
+ abstract fun setMulticastTTL(ttl: Double): Double
142
+
143
+ @DoNotStrip
144
+ @Keep
145
+ abstract fun setMulticastLoopback(flag: Boolean): Double
146
+
147
+ @DoNotStrip
148
+ @Keep
149
+ abstract fun setMulticastInterface(interfaceAddress: String): Double
150
+
151
+ @DoNotStrip
152
+ @Keep
153
+ abstract fun addMembership(multicastAddress: String, interfaceAddress: String?): Double
154
+
155
+ @DoNotStrip
156
+ @Keep
157
+ abstract fun dropMembership(multicastAddress: String, interfaceAddress: String?): Double
158
+
159
+ @DoNotStrip
160
+ @Keep
161
+ abstract fun addSourceSpecificMembership(sourceAddress: String, groupAddress: String, interfaceAddress: String?): Double
162
+
163
+ @DoNotStrip
164
+ @Keep
165
+ abstract fun dropSourceSpecificMembership(sourceAddress: String, groupAddress: String, interfaceAddress: String?): Double
166
+
167
+ @DoNotStrip
168
+ @Keep
169
+ abstract fun getLocalAddress(): String
170
+
171
+ @DoNotStrip
172
+ @Keep
173
+ abstract fun getLocalPort(): Double
174
+
175
+ @DoNotStrip
176
+ @Keep
177
+ abstract fun getRemoteAddress(): String
178
+
179
+ @DoNotStrip
180
+ @Keep
181
+ abstract fun getRemotePort(): Double
182
+
183
+ @DoNotStrip
184
+ @Keep
185
+ abstract fun getRecvBufferSize(): Double
186
+
187
+ @DoNotStrip
188
+ @Keep
189
+ abstract fun setRecvBufferSize(size: Double): Double
190
+
191
+ @DoNotStrip
192
+ @Keep
193
+ abstract fun getSendBufferSize(): Double
194
+
195
+ @DoNotStrip
196
+ @Keep
197
+ abstract fun setSendBufferSize(size: Double): Double
198
+
199
+ @DoNotStrip
200
+ @Keep
201
+ abstract fun getSendQueueCount(): Double
202
+
203
+ @DoNotStrip
204
+ @Keep
205
+ abstract fun getSendQueueSize(): Double
206
+
207
+ private external fun initHybrid(): HybridData
208
+
209
+ companion object {
210
+ protected const val TAG = "HybridUdpSocketDriverSpec"
211
+ }
212
+ }
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// RustCUdpOnLoad.kt
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ package com.margelo.nitro.udp
9
+
10
+ import android.util.Log
11
+
12
+ internal class RustCUdpOnLoad {
13
+ companion object {
14
+ private const val TAG = "RustCUdpOnLoad"
15
+ private var didLoad = false
16
+ /**
17
+ * Initializes the native part of "RustCUdp".
18
+ * This method is idempotent and can be called more than once.
19
+ */
20
+ @JvmStatic
21
+ fun initializeNative() {
22
+ if (didLoad) return
23
+ try {
24
+ Log.i(TAG, "Loading RustCUdp C++ library...")
25
+ System.loadLibrary("RustCUdp")
26
+ Log.i(TAG, "Successfully loaded RustCUdp C++ library!")
27
+ didLoad = true
28
+ } catch (e: Error) {
29
+ Log.e(TAG, "Failed to load RustCUdp C++ library! Is it properly installed and linked? " +
30
+ "Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
31
+ throw e
32
+ }
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,60 @@
1
+ #
2
+ # RustCUdp+autolinking.rb
3
+ # This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ # https://github.com/mrousavy/nitro
5
+ # Copyright © 2025 Marc Rousavy @ Margelo
6
+ #
7
+
8
+ # This is a Ruby script that adds all files generated by Nitrogen
9
+ # to the given podspec.
10
+ #
11
+ # To use it, add this to your .podspec:
12
+ # ```ruby
13
+ # Pod::Spec.new do |spec|
14
+ # # ...
15
+ #
16
+ # # Add all files generated by Nitrogen
17
+ # load 'nitrogen/generated/ios/RustCUdp+autolinking.rb'
18
+ # add_nitrogen_files(spec)
19
+ # end
20
+ # ```
21
+
22
+ def add_nitrogen_files(spec)
23
+ Pod::UI.puts "[NitroModules] 🔥 RustCUdp is boosted by nitro!"
24
+
25
+ spec.dependency "NitroModules"
26
+
27
+ current_source_files = Array(spec.attributes_hash['source_files'])
28
+ spec.source_files = current_source_files + [
29
+ # Generated cross-platform specs
30
+ "nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
31
+ # Generated bridges for the cross-platform specs
32
+ "nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
33
+ ]
34
+
35
+ current_public_header_files = Array(spec.attributes_hash['public_header_files'])
36
+ spec.public_header_files = current_public_header_files + [
37
+ # Generated specs
38
+ "nitrogen/generated/shared/**/*.{h,hpp}",
39
+ # Swift to C++ bridging helpers
40
+ "nitrogen/generated/ios/RustCUdp-Swift-Cxx-Bridge.hpp"
41
+ ]
42
+
43
+ current_private_header_files = Array(spec.attributes_hash['private_header_files'])
44
+ spec.private_header_files = current_private_header_files + [
45
+ # iOS specific specs
46
+ "nitrogen/generated/ios/c++/**/*.{h,hpp}",
47
+ # Views are framework-specific and should be private
48
+ "nitrogen/generated/shared/**/views/**/*"
49
+ ]
50
+
51
+ current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
52
+ spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
53
+ # Use C++ 20
54
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
55
+ # Enables C++ <-> Swift interop (by default it's only ObjC)
56
+ "SWIFT_OBJC_INTEROP_MODE" => "objcxx",
57
+ # Enables stricter modular headers
58
+ "DEFINES_MODULE" => "YES",
59
+ })
60
+ end
@@ -0,0 +1,74 @@
1
+ ///
2
+ /// RustCUdp-Swift-Cxx-Bridge.cpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #include "RustCUdp-Swift-Cxx-Bridge.hpp"
9
+
10
+ // Include C++ implementation defined types
11
+ #include "HybridUdpDriverSpecSwift.hpp"
12
+ #include "HybridUdpSocketDriverSpecSwift.hpp"
13
+ #include "RustCUdp-Swift-Cxx-Umbrella.hpp"
14
+ #include <NitroModules/NitroDefines.hpp>
15
+
16
+ namespace margelo::nitro::udp::bridge::swift {
17
+
18
+ // pragma MARK: std::function<void(const std::shared_ptr<ArrayBuffer>& /* data */, const std::string& /* address */, double /* port */)>
19
+ Func_void_std__shared_ptr_ArrayBuffer__std__string_double create_Func_void_std__shared_ptr_ArrayBuffer__std__string_double(void* NON_NULL swiftClosureWrapper) noexcept {
20
+ auto swiftClosure = RustCUdp::Func_void_std__shared_ptr_ArrayBuffer__std__string_double::fromUnsafe(swiftClosureWrapper);
21
+ return [swiftClosure = std::move(swiftClosure)](const std::shared_ptr<ArrayBuffer>& data, const std::string& address, double port) mutable -> void {
22
+ swiftClosure.call(ArrayBufferHolder(data), address, port);
23
+ };
24
+ }
25
+
26
+ // pragma MARK: std::function<void()>
27
+ Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
28
+ auto swiftClosure = RustCUdp::Func_void::fromUnsafe(swiftClosureWrapper);
29
+ return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
30
+ swiftClosure.call();
31
+ };
32
+ }
33
+
34
+ // pragma MARK: std::function<void(const std::string& /* error */)>
35
+ Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
36
+ auto swiftClosure = RustCUdp::Func_void_std__string::fromUnsafe(swiftClosureWrapper);
37
+ return [swiftClosure = std::move(swiftClosure)](const std::string& error) mutable -> void {
38
+ swiftClosure.call(error);
39
+ };
40
+ }
41
+
42
+ // pragma MARK: std::shared_ptr<HybridUdpSocketDriverSpec>
43
+ std::shared_ptr<HybridUdpSocketDriverSpec> create_std__shared_ptr_HybridUdpSocketDriverSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
44
+ RustCUdp::HybridUdpSocketDriverSpec_cxx swiftPart = RustCUdp::HybridUdpSocketDriverSpec_cxx::fromUnsafe(swiftUnsafePointer);
45
+ return std::make_shared<margelo::nitro::udp::HybridUdpSocketDriverSpecSwift>(swiftPart);
46
+ }
47
+ void* NON_NULL get_std__shared_ptr_HybridUdpSocketDriverSpec_(std__shared_ptr_HybridUdpSocketDriverSpec_ cppType) {
48
+ std::shared_ptr<margelo::nitro::udp::HybridUdpSocketDriverSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::udp::HybridUdpSocketDriverSpecSwift>(cppType);
49
+ #ifdef NITRO_DEBUG
50
+ if (swiftWrapper == nullptr) [[unlikely]] {
51
+ throw std::runtime_error("Class \"HybridUdpSocketDriverSpec\" is not implemented in Swift!");
52
+ }
53
+ #endif
54
+ RustCUdp::HybridUdpSocketDriverSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
55
+ return swiftPart.toUnsafe();
56
+ }
57
+
58
+ // pragma MARK: std::shared_ptr<HybridUdpDriverSpec>
59
+ std::shared_ptr<HybridUdpDriverSpec> create_std__shared_ptr_HybridUdpDriverSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
60
+ RustCUdp::HybridUdpDriverSpec_cxx swiftPart = RustCUdp::HybridUdpDriverSpec_cxx::fromUnsafe(swiftUnsafePointer);
61
+ return std::make_shared<margelo::nitro::udp::HybridUdpDriverSpecSwift>(swiftPart);
62
+ }
63
+ void* NON_NULL get_std__shared_ptr_HybridUdpDriverSpec_(std__shared_ptr_HybridUdpDriverSpec_ cppType) {
64
+ std::shared_ptr<margelo::nitro::udp::HybridUdpDriverSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::udp::HybridUdpDriverSpecSwift>(cppType);
65
+ #ifdef NITRO_DEBUG
66
+ if (swiftWrapper == nullptr) [[unlikely]] {
67
+ throw std::runtime_error("Class \"HybridUdpDriverSpec\" is not implemented in Swift!");
68
+ }
69
+ #endif
70
+ RustCUdp::HybridUdpDriverSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
71
+ return swiftPart.toUnsafe();
72
+ }
73
+
74
+ } // namespace margelo::nitro::udp::bridge::swift