react-native-nitro-net 0.2.0 → 0.3.1
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.
- package/README.md +70 -12
- package/android/libs/arm64-v8a/librust_c_net.so +0 -0
- package/android/libs/armeabi-v7a/librust_c_net.so +0 -0
- package/android/libs/x86/librust_c_net.so +0 -0
- package/android/libs/x86_64/librust_c_net.so +0 -0
- package/cpp/HybridHttpParser.hpp +67 -0
- package/cpp/HybridNetDriver.hpp +6 -0
- package/cpp/HybridNetServerDriver.hpp +7 -0
- package/cpp/HybridNetSocketDriver.hpp +27 -0
- package/cpp/NetBindings.hpp +15 -0
- package/ios/Frameworks/RustCNet.xcframework/Info.plist +5 -5
- package/ios/Frameworks/RustCNet.xcframework/ios-arm64/RustCNet.framework/RustCNet +0 -0
- package/ios/Frameworks/RustCNet.xcframework/ios-arm64_x86_64-simulator/RustCNet.framework/RustCNet +0 -0
- package/lib/Driver.d.ts +1 -0
- package/lib/Driver.d.ts.map +1 -0
- package/lib/Driver.js +2 -5
- package/lib/Net.nitro.d.ts +20 -0
- package/lib/Net.nitro.d.ts.map +1 -0
- package/lib/Net.nitro.js +4 -7
- package/lib/http.d.ts +204 -0
- package/lib/http.d.ts.map +1 -0
- package/lib/http.js +1126 -0
- package/lib/https.d.ts +25 -0
- package/lib/https.d.ts.map +1 -0
- package/lib/https.js +102 -0
- package/lib/index.d.ts +41 -160
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -821
- package/lib/net.d.ts +197 -0
- package/lib/net.d.ts.map +1 -0
- package/lib/net.js +875 -0
- package/lib/tls.d.ts +23 -1
- package/lib/tls.d.ts.map +1 -0
- package/lib/tls.js +108 -54
- package/nitrogen/generated/android/RustCNet+autolinking.cmake +2 -0
- package/nitrogen/generated/android/RustCNetOnLoad.cpp +2 -0
- package/nitrogen/generated/android/c++/JHybridHttpParserSpec.cpp +54 -0
- package/nitrogen/generated/android/c++/JHybridHttpParserSpec.hpp +65 -0
- package/nitrogen/generated/android/c++/JHybridNetDriverSpec.cpp +9 -0
- package/nitrogen/generated/android/c++/JHybridNetDriverSpec.hpp +1 -0
- package/nitrogen/generated/android/c++/JHybridNetServerDriverSpec.cpp +4 -0
- package/nitrogen/generated/android/c++/JHybridNetServerDriverSpec.hpp +1 -0
- package/nitrogen/generated/android/c++/JHybridNetSocketDriverSpec.cpp +9 -0
- package/nitrogen/generated/android/c++/JHybridNetSocketDriverSpec.hpp +2 -0
- package/nitrogen/generated/android/c++/JNetConfig.hpp +7 -3
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/net/HybridHttpParserSpec.kt +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/net/HybridNetDriverSpec.kt +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/net/HybridNetServerDriverSpec.kt +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/net/HybridNetSocketDriverSpec.kt +8 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/net/NetConfig.kt +6 -3
- package/nitrogen/generated/ios/RustCNet-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/RustCNet-Swift-Cxx-Bridge.hpp +26 -0
- package/nitrogen/generated/ios/RustCNet-Swift-Cxx-Umbrella.hpp +5 -0
- package/nitrogen/generated/ios/c++/HybridHttpParserSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridHttpParserSpecSwift.hpp +79 -0
- package/nitrogen/generated/ios/c++/HybridNetDriverSpecSwift.hpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNetServerDriverSpecSwift.hpp +6 -0
- package/nitrogen/generated/ios/c++/HybridNetSocketDriverSpecSwift.hpp +14 -0
- package/nitrogen/generated/ios/swift/HybridHttpParserSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridHttpParserSpec_cxx.swift +131 -0
- package/nitrogen/generated/ios/swift/HybridNetDriverSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridNetDriverSpec_cxx.swift +15 -0
- package/nitrogen/generated/ios/swift/HybridNetServerDriverSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridNetServerDriverSpec_cxx.swift +11 -0
- package/nitrogen/generated/ios/swift/HybridNetSocketDriverSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridNetSocketDriverSpec_cxx.swift +36 -0
- package/nitrogen/generated/ios/swift/NetConfig.swift +19 -1
- package/nitrogen/generated/shared/c++/HybridHttpParserSpec.cpp +21 -0
- package/nitrogen/generated/shared/c++/HybridHttpParserSpec.hpp +63 -0
- package/nitrogen/generated/shared/c++/HybridNetDriverSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridNetDriverSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/HybridNetServerDriverSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridNetServerDriverSpec.hpp +1 -0
- package/nitrogen/generated/shared/c++/HybridNetSocketDriverSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridNetSocketDriverSpec.hpp +2 -0
- package/nitrogen/generated/shared/c++/NetConfig.hpp +6 -2
- package/package.json +9 -7
- package/src/Net.nitro.ts +17 -0
- package/src/http.ts +1303 -0
- package/src/https.ts +125 -0
- package/src/index.ts +13 -874
- package/src/net.ts +1005 -0
- package/src/tls.ts +82 -6
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridHttpParserSpec.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.net
|
|
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 HttpParser HybridObject.
|
|
18
|
+
* Implement this abstract class to create Kotlin-based instances of HttpParser.
|
|
19
|
+
*/
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
@Suppress(
|
|
23
|
+
"KotlinJniMissingFunction", "unused",
|
|
24
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
25
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
26
|
+
)
|
|
27
|
+
abstract class HybridHttpParserSpec: 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 HttpParser]"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Properties
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
// Methods
|
|
49
|
+
@DoNotStrip
|
|
50
|
+
@Keep
|
|
51
|
+
abstract fun feed(data: ArrayBuffer): String
|
|
52
|
+
|
|
53
|
+
private external fun initHybrid(): HybridData
|
|
54
|
+
|
|
55
|
+
companion object {
|
|
56
|
+
protected const val TAG = "HybridHttpParserSpec"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -54,6 +54,10 @@ abstract class HybridNetDriverSpec: HybridObject() {
|
|
|
54
54
|
@Keep
|
|
55
55
|
abstract fun createServer(): HybridNetServerDriverSpec
|
|
56
56
|
|
|
57
|
+
@DoNotStrip
|
|
58
|
+
@Keep
|
|
59
|
+
abstract fun createHttpParser(mode: Double): HybridHttpParserSpec
|
|
60
|
+
|
|
57
61
|
@DoNotStrip
|
|
58
62
|
@Keep
|
|
59
63
|
abstract fun createSecureContext(cert: String, key: String, passphrase: String?): Double
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/net/HybridNetServerDriverSpec.kt
CHANGED
|
@@ -76,6 +76,10 @@ abstract class HybridNetServerDriverSpec: HybridObject() {
|
|
|
76
76
|
@Keep
|
|
77
77
|
abstract fun listenUnix(path: String, backlog: Double?): Unit
|
|
78
78
|
|
|
79
|
+
@DoNotStrip
|
|
80
|
+
@Keep
|
|
81
|
+
abstract fun listenTLSUnix(path: String, secureContextId: Double, backlog: Double?): Unit
|
|
82
|
+
|
|
79
83
|
@DoNotStrip
|
|
80
84
|
@Keep
|
|
81
85
|
abstract fun listenHandle(fd: Double, backlog: Double?): Unit
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/net/HybridNetSocketDriverSpec.kt
CHANGED
|
@@ -158,6 +158,14 @@ abstract class HybridNetSocketDriverSpec: HybridObject() {
|
|
|
158
158
|
@Keep
|
|
159
159
|
abstract fun enableKeylog(): Unit
|
|
160
160
|
|
|
161
|
+
@DoNotStrip
|
|
162
|
+
@Keep
|
|
163
|
+
abstract fun enableTrace(): Unit
|
|
164
|
+
|
|
165
|
+
@DoNotStrip
|
|
166
|
+
@Keep
|
|
167
|
+
abstract fun exportKeyingMaterial(length: Double, label: String, context: ArrayBuffer?): ArrayBuffer?
|
|
168
|
+
|
|
161
169
|
@DoNotStrip
|
|
162
170
|
@Keep
|
|
163
171
|
abstract fun setNoDelay(enable: Boolean): Unit
|
|
@@ -19,7 +19,10 @@ import com.facebook.proguard.annotations.DoNotStrip
|
|
|
19
19
|
data class NetConfig(
|
|
20
20
|
@DoNotStrip
|
|
21
21
|
@Keep
|
|
22
|
-
val workerThreads: Double
|
|
22
|
+
val workerThreads: Double?,
|
|
23
|
+
@DoNotStrip
|
|
24
|
+
@Keep
|
|
25
|
+
val debug: Boolean?
|
|
23
26
|
) {
|
|
24
27
|
/* primary constructor */
|
|
25
28
|
|
|
@@ -31,8 +34,8 @@ data class NetConfig(
|
|
|
31
34
|
@Keep
|
|
32
35
|
@Suppress("unused")
|
|
33
36
|
@JvmStatic
|
|
34
|
-
private fun fromCpp(workerThreads: Double?): NetConfig {
|
|
35
|
-
return NetConfig(workerThreads)
|
|
37
|
+
private fun fromCpp(workerThreads: Double?, debug: Boolean?): NetConfig {
|
|
38
|
+
return NetConfig(workerThreads, debug)
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
#include "RustCNet-Swift-Cxx-Bridge.hpp"
|
|
9
9
|
|
|
10
10
|
// Include C++ implementation defined types
|
|
11
|
+
#include "HybridHttpParserSpecSwift.hpp"
|
|
11
12
|
#include "HybridNetDriverSpecSwift.hpp"
|
|
12
13
|
#include "HybridNetServerDriverSpecSwift.hpp"
|
|
13
14
|
#include "HybridNetSocketDriverSpecSwift.hpp"
|
|
@@ -56,6 +57,22 @@ namespace margelo::nitro::net::bridge::swift {
|
|
|
56
57
|
return swiftPart.toUnsafe();
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
// pragma MARK: std::shared_ptr<HybridHttpParserSpec>
|
|
61
|
+
std::shared_ptr<HybridHttpParserSpec> create_std__shared_ptr_HybridHttpParserSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
62
|
+
RustCNet::HybridHttpParserSpec_cxx swiftPart = RustCNet::HybridHttpParserSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
63
|
+
return std::make_shared<margelo::nitro::net::HybridHttpParserSpecSwift>(swiftPart);
|
|
64
|
+
}
|
|
65
|
+
void* NON_NULL get_std__shared_ptr_HybridHttpParserSpec_(std__shared_ptr_HybridHttpParserSpec_ cppType) {
|
|
66
|
+
std::shared_ptr<margelo::nitro::net::HybridHttpParserSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::net::HybridHttpParserSpecSwift>(cppType);
|
|
67
|
+
#ifdef NITRO_DEBUG
|
|
68
|
+
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
69
|
+
throw std::runtime_error("Class \"HybridHttpParserSpec\" is not implemented in Swift!");
|
|
70
|
+
}
|
|
71
|
+
#endif
|
|
72
|
+
RustCNet::HybridHttpParserSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
73
|
+
return swiftPart.toUnsafe();
|
|
74
|
+
}
|
|
75
|
+
|
|
59
76
|
// pragma MARK: std::shared_ptr<HybridNetDriverSpec>
|
|
60
77
|
std::shared_ptr<HybridNetDriverSpec> create_std__shared_ptr_HybridNetDriverSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
61
78
|
RustCNet::HybridNetDriverSpec_cxx swiftPart = RustCNet::HybridNetDriverSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
// Forward declarations of C++ defined types
|
|
11
11
|
// Forward declaration of `ArrayBufferHolder` to properly resolve imports.
|
|
12
12
|
namespace NitroModules { class ArrayBufferHolder; }
|
|
13
|
+
// Forward declaration of `HybridHttpParserSpec` to properly resolve imports.
|
|
14
|
+
namespace margelo::nitro::net { class HybridHttpParserSpec; }
|
|
13
15
|
// Forward declaration of `HybridNetDriverSpec` to properly resolve imports.
|
|
14
16
|
namespace margelo::nitro::net { class HybridNetDriverSpec; }
|
|
15
17
|
// Forward declaration of `HybridNetServerDriverSpec` to properly resolve imports.
|
|
@@ -18,6 +20,8 @@ namespace margelo::nitro::net { class HybridNetServerDriverSpec; }
|
|
|
18
20
|
namespace margelo::nitro::net { class HybridNetSocketDriverSpec; }
|
|
19
21
|
|
|
20
22
|
// Forward declarations of Swift defined types
|
|
23
|
+
// Forward declaration of `HybridHttpParserSpec_cxx` to properly resolve imports.
|
|
24
|
+
namespace RustCNet { class HybridHttpParserSpec_cxx; }
|
|
21
25
|
// Forward declaration of `HybridNetDriverSpec_cxx` to properly resolve imports.
|
|
22
26
|
namespace RustCNet { class HybridNetDriverSpec_cxx; }
|
|
23
27
|
// Forward declaration of `HybridNetServerDriverSpec_cxx` to properly resolve imports.
|
|
@@ -26,6 +30,7 @@ namespace RustCNet { class HybridNetServerDriverSpec_cxx; }
|
|
|
26
30
|
namespace RustCNet { class HybridNetSocketDriverSpec_cxx; }
|
|
27
31
|
|
|
28
32
|
// Include C++ defined types
|
|
33
|
+
#include "HybridHttpParserSpec.hpp"
|
|
29
34
|
#include "HybridNetDriverSpec.hpp"
|
|
30
35
|
#include "HybridNetServerDriverSpec.hpp"
|
|
31
36
|
#include "HybridNetSocketDriverSpec.hpp"
|
|
@@ -195,6 +200,18 @@ namespace margelo::nitro::net::bridge::swift {
|
|
|
195
200
|
using std__weak_ptr_HybridNetServerDriverSpec_ = std::weak_ptr<HybridNetServerDriverSpec>;
|
|
196
201
|
inline std__weak_ptr_HybridNetServerDriverSpec_ weakify_std__shared_ptr_HybridNetServerDriverSpec_(const std::shared_ptr<HybridNetServerDriverSpec>& strong) noexcept { return strong; }
|
|
197
202
|
|
|
203
|
+
// pragma MARK: std::shared_ptr<HybridHttpParserSpec>
|
|
204
|
+
/**
|
|
205
|
+
* Specialized version of `std::shared_ptr<HybridHttpParserSpec>`.
|
|
206
|
+
*/
|
|
207
|
+
using std__shared_ptr_HybridHttpParserSpec_ = std::shared_ptr<HybridHttpParserSpec>;
|
|
208
|
+
std::shared_ptr<HybridHttpParserSpec> create_std__shared_ptr_HybridHttpParserSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
209
|
+
void* NON_NULL get_std__shared_ptr_HybridHttpParserSpec_(std__shared_ptr_HybridHttpParserSpec_ cppType);
|
|
210
|
+
|
|
211
|
+
// pragma MARK: std::weak_ptr<HybridHttpParserSpec>
|
|
212
|
+
using std__weak_ptr_HybridHttpParserSpec_ = std::weak_ptr<HybridHttpParserSpec>;
|
|
213
|
+
inline std__weak_ptr_HybridHttpParserSpec_ weakify_std__shared_ptr_HybridHttpParserSpec_(const std::shared_ptr<HybridHttpParserSpec>& strong) noexcept { return strong; }
|
|
214
|
+
|
|
198
215
|
// pragma MARK: std::shared_ptr<HybridNetDriverSpec>
|
|
199
216
|
/**
|
|
200
217
|
* Specialized version of `std::shared_ptr<HybridNetDriverSpec>`.
|
|
@@ -225,6 +242,15 @@ namespace margelo::nitro::net::bridge::swift {
|
|
|
225
242
|
return Result<std::shared_ptr<HybridNetServerDriverSpec>>::withError(error);
|
|
226
243
|
}
|
|
227
244
|
|
|
245
|
+
// pragma MARK: Result<std::shared_ptr<HybridHttpParserSpec>>
|
|
246
|
+
using Result_std__shared_ptr_HybridHttpParserSpec__ = Result<std::shared_ptr<HybridHttpParserSpec>>;
|
|
247
|
+
inline Result_std__shared_ptr_HybridHttpParserSpec__ create_Result_std__shared_ptr_HybridHttpParserSpec__(const std::shared_ptr<HybridHttpParserSpec>& value) noexcept {
|
|
248
|
+
return Result<std::shared_ptr<HybridHttpParserSpec>>::withValue(value);
|
|
249
|
+
}
|
|
250
|
+
inline Result_std__shared_ptr_HybridHttpParserSpec__ create_Result_std__shared_ptr_HybridHttpParserSpec__(const std::exception_ptr& error) noexcept {
|
|
251
|
+
return Result<std::shared_ptr<HybridHttpParserSpec>>::withError(error);
|
|
252
|
+
}
|
|
253
|
+
|
|
228
254
|
// pragma MARK: Result<double>
|
|
229
255
|
using Result_double_ = Result<double>;
|
|
230
256
|
inline Result_double_ create_Result_double_(double value) noexcept {
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
10
|
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridHttpParserSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::net { class HybridHttpParserSpec; }
|
|
11
13
|
// Forward declaration of `HybridNetDriverSpec` to properly resolve imports.
|
|
12
14
|
namespace margelo::nitro::net { class HybridNetDriverSpec; }
|
|
13
15
|
// Forward declaration of `HybridNetServerDriverSpec` to properly resolve imports.
|
|
@@ -18,6 +20,7 @@ namespace margelo::nitro::net { class HybridNetSocketDriverSpec; }
|
|
|
18
20
|
namespace margelo::nitro::net { struct NetConfig; }
|
|
19
21
|
|
|
20
22
|
// Include C++ defined types
|
|
23
|
+
#include "HybridHttpParserSpec.hpp"
|
|
21
24
|
#include "HybridNetDriverSpec.hpp"
|
|
22
25
|
#include "HybridNetServerDriverSpec.hpp"
|
|
23
26
|
#include "HybridNetSocketDriverSpec.hpp"
|
|
@@ -40,6 +43,8 @@ namespace margelo::nitro::net { struct NetConfig; }
|
|
|
40
43
|
#include <NitroModules/DateToChronoDate.hpp>
|
|
41
44
|
|
|
42
45
|
// Forward declarations of Swift defined types
|
|
46
|
+
// Forward declaration of `HybridHttpParserSpec_cxx` to properly resolve imports.
|
|
47
|
+
namespace RustCNet { class HybridHttpParserSpec_cxx; }
|
|
43
48
|
// Forward declaration of `HybridNetDriverSpec_cxx` to properly resolve imports.
|
|
44
49
|
namespace RustCNet { class HybridNetDriverSpec_cxx; }
|
|
45
50
|
// Forward declaration of `HybridNetServerDriverSpec_cxx` to properly resolve imports.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridHttpParserSpecSwift.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 "HybridHttpParserSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::net {
|
|
11
|
+
} // namespace margelo::nitro::net
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridHttpParserSpecSwift.hpp
|
|
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
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "HybridHttpParserSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridHttpParserSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace RustCNet { class HybridHttpParserSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `ArrayBufferHolder` to properly resolve imports.
|
|
16
|
+
namespace NitroModules { class ArrayBufferHolder; }
|
|
17
|
+
|
|
18
|
+
#include <string>
|
|
19
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
20
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
21
|
+
|
|
22
|
+
#include "RustCNet-Swift-Cxx-Umbrella.hpp"
|
|
23
|
+
|
|
24
|
+
namespace margelo::nitro::net {
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The C++ part of HybridHttpParserSpec_cxx.swift.
|
|
28
|
+
*
|
|
29
|
+
* HybridHttpParserSpecSwift (C++) accesses HybridHttpParserSpec_cxx (Swift), and might
|
|
30
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
31
|
+
*
|
|
32
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
33
|
+
* the future, HybridHttpParserSpec_cxx can directly inherit from the C++ class HybridHttpParserSpec
|
|
34
|
+
* to simplify the whole structure and memory management.
|
|
35
|
+
*/
|
|
36
|
+
class HybridHttpParserSpecSwift: public virtual HybridHttpParserSpec {
|
|
37
|
+
public:
|
|
38
|
+
// Constructor from a Swift instance
|
|
39
|
+
explicit HybridHttpParserSpecSwift(const RustCNet::HybridHttpParserSpec_cxx& swiftPart):
|
|
40
|
+
HybridObject(HybridHttpParserSpec::TAG),
|
|
41
|
+
_swiftPart(swiftPart) { }
|
|
42
|
+
|
|
43
|
+
public:
|
|
44
|
+
// Get the Swift part
|
|
45
|
+
inline RustCNet::HybridHttpParserSpec_cxx& getSwiftPart() noexcept {
|
|
46
|
+
return _swiftPart;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
51
|
+
return _swiftPart.getMemorySize();
|
|
52
|
+
}
|
|
53
|
+
void dispose() noexcept override {
|
|
54
|
+
_swiftPart.dispose();
|
|
55
|
+
}
|
|
56
|
+
std::string toString() override {
|
|
57
|
+
return _swiftPart.toString();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public:
|
|
61
|
+
// Properties
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
public:
|
|
65
|
+
// Methods
|
|
66
|
+
inline std::string feed(const std::shared_ptr<ArrayBuffer>& data) override {
|
|
67
|
+
auto __result = _swiftPart.feed(ArrayBufferHolder(data));
|
|
68
|
+
if (__result.hasError()) [[unlikely]] {
|
|
69
|
+
std::rethrow_exception(__result.error());
|
|
70
|
+
}
|
|
71
|
+
auto __value = std::move(__result.value());
|
|
72
|
+
return __value;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private:
|
|
76
|
+
RustCNet::HybridHttpParserSpec_cxx _swiftPart;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
} // namespace margelo::nitro::net
|
|
@@ -16,6 +16,8 @@ namespace RustCNet { class HybridNetDriverSpec_cxx; }
|
|
|
16
16
|
namespace margelo::nitro::net { class HybridNetSocketDriverSpec; }
|
|
17
17
|
// Forward declaration of `HybridNetServerDriverSpec` to properly resolve imports.
|
|
18
18
|
namespace margelo::nitro::net { class HybridNetServerDriverSpec; }
|
|
19
|
+
// Forward declaration of `HybridHttpParserSpec` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::net { class HybridHttpParserSpec; }
|
|
19
21
|
// Forward declaration of `ArrayBufferHolder` to properly resolve imports.
|
|
20
22
|
namespace NitroModules { class ArrayBufferHolder; }
|
|
21
23
|
// Forward declaration of `NetConfig` to properly resolve imports.
|
|
@@ -26,6 +28,7 @@ namespace margelo::nitro::net { struct NetConfig; }
|
|
|
26
28
|
#include <string>
|
|
27
29
|
#include <optional>
|
|
28
30
|
#include "HybridNetServerDriverSpec.hpp"
|
|
31
|
+
#include "HybridHttpParserSpec.hpp"
|
|
29
32
|
#include <NitroModules/ArrayBuffer.hpp>
|
|
30
33
|
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
31
34
|
#include "NetConfig.hpp"
|
|
@@ -90,6 +93,14 @@ namespace margelo::nitro::net {
|
|
|
90
93
|
auto __value = std::move(__result.value());
|
|
91
94
|
return __value;
|
|
92
95
|
}
|
|
96
|
+
inline std::shared_ptr<HybridHttpParserSpec> createHttpParser(double mode) override {
|
|
97
|
+
auto __result = _swiftPart.createHttpParser(std::forward<decltype(mode)>(mode));
|
|
98
|
+
if (__result.hasError()) [[unlikely]] {
|
|
99
|
+
std::rethrow_exception(__result.error());
|
|
100
|
+
}
|
|
101
|
+
auto __value = std::move(__result.value());
|
|
102
|
+
return __value;
|
|
103
|
+
}
|
|
93
104
|
inline double createSecureContext(const std::string& cert, const std::string& key, const std::optional<std::string>& passphrase) override {
|
|
94
105
|
auto __result = _swiftPart.createSecureContext(cert, key, passphrase);
|
|
95
106
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -95,6 +95,12 @@ namespace margelo::nitro::net {
|
|
|
95
95
|
std::rethrow_exception(__result.error());
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
inline void listenTLSUnix(const std::string& path, double secureContextId, std::optional<double> backlog) override {
|
|
99
|
+
auto __result = _swiftPart.listenTLSUnix(path, std::forward<decltype(secureContextId)>(secureContextId), backlog);
|
|
100
|
+
if (__result.hasError()) [[unlikely]] {
|
|
101
|
+
std::rethrow_exception(__result.error());
|
|
102
|
+
}
|
|
103
|
+
}
|
|
98
104
|
inline void listenHandle(double fd, std::optional<double> backlog) override {
|
|
99
105
|
auto __result = _swiftPart.listenHandle(std::forward<decltype(fd)>(fd), backlog);
|
|
100
106
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -236,6 +236,20 @@ namespace margelo::nitro::net {
|
|
|
236
236
|
std::rethrow_exception(__result.error());
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
+
inline void enableTrace() override {
|
|
240
|
+
auto __result = _swiftPart.enableTrace();
|
|
241
|
+
if (__result.hasError()) [[unlikely]] {
|
|
242
|
+
std::rethrow_exception(__result.error());
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
inline std::optional<std::shared_ptr<ArrayBuffer>> exportKeyingMaterial(double length, const std::string& label, const std::optional<std::shared_ptr<ArrayBuffer>>& context) override {
|
|
246
|
+
auto __result = _swiftPart.exportKeyingMaterial(std::forward<decltype(length)>(length), label, context);
|
|
247
|
+
if (__result.hasError()) [[unlikely]] {
|
|
248
|
+
std::rethrow_exception(__result.error());
|
|
249
|
+
}
|
|
250
|
+
auto __value = std::move(__result.value());
|
|
251
|
+
return __value;
|
|
252
|
+
}
|
|
239
253
|
inline void setNoDelay(bool enable) override {
|
|
240
254
|
auto __result = _swiftPart.setNoDelay(std::forward<decltype(enable)>(enable));
|
|
241
255
|
if (__result.hasError()) [[unlikely]] {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridHttpParserSpec.swift
|
|
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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/// See ``HybridHttpParserSpec``
|
|
12
|
+
public protocol HybridHttpParserSpec_protocol: HybridObject {
|
|
13
|
+
// Properties
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// Methods
|
|
17
|
+
func feed(data: ArrayBuffer) throws -> String
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public extension HybridHttpParserSpec_protocol {
|
|
21
|
+
/// Default implementation of ``HybridObject.toString``
|
|
22
|
+
func toString() -> String {
|
|
23
|
+
return "[HybridObject HttpParser]"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/// See ``HybridHttpParserSpec``
|
|
28
|
+
open class HybridHttpParserSpec_base {
|
|
29
|
+
private weak var cxxWrapper: HybridHttpParserSpec_cxx? = nil
|
|
30
|
+
public init() { }
|
|
31
|
+
public func getCxxWrapper() -> HybridHttpParserSpec_cxx {
|
|
32
|
+
#if DEBUG
|
|
33
|
+
guard self is HybridHttpParserSpec else {
|
|
34
|
+
fatalError("`self` is not a `HybridHttpParserSpec`! Did you accidentally inherit from `HybridHttpParserSpec_base` instead of `HybridHttpParserSpec`?")
|
|
35
|
+
}
|
|
36
|
+
#endif
|
|
37
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
38
|
+
return cxxWrapper
|
|
39
|
+
} else {
|
|
40
|
+
let cxxWrapper = HybridHttpParserSpec_cxx(self as! HybridHttpParserSpec)
|
|
41
|
+
self.cxxWrapper = cxxWrapper
|
|
42
|
+
return cxxWrapper
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* A Swift base-protocol representing the HttpParser HybridObject.
|
|
49
|
+
* Implement this protocol to create Swift-based instances of HttpParser.
|
|
50
|
+
* ```swift
|
|
51
|
+
* class HybridHttpParser : HybridHttpParserSpec {
|
|
52
|
+
* // ...
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
public typealias HybridHttpParserSpec = HybridHttpParserSpec_protocol & HybridHttpParserSpec_base
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridHttpParserSpec_cxx.swift
|
|
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
|
+
import Foundation
|
|
9
|
+
import NitroModules
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A class implementation that bridges HybridHttpParserSpec over to C++.
|
|
13
|
+
* In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
|
|
14
|
+
*
|
|
15
|
+
* Also, some Swift types need to be bridged with special handling:
|
|
16
|
+
* - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
|
|
17
|
+
* - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
|
|
18
|
+
* - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
|
|
19
|
+
*/
|
|
20
|
+
open class HybridHttpParserSpec_cxx {
|
|
21
|
+
/**
|
|
22
|
+
* The Swift <> C++ bridge's namespace (`margelo::nitro::net::bridge::swift`)
|
|
23
|
+
* from `RustCNet-Swift-Cxx-Bridge.hpp`.
|
|
24
|
+
* This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
|
|
25
|
+
*/
|
|
26
|
+
public typealias bridge = margelo.nitro.net.bridge.swift
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Holds an instance of the `HybridHttpParserSpec` Swift protocol.
|
|
30
|
+
*/
|
|
31
|
+
private var __implementation: any HybridHttpParserSpec
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
|
35
|
+
*/
|
|
36
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridHttpParserSpec_
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Create a new `HybridHttpParserSpec_cxx` that wraps the given `HybridHttpParserSpec`.
|
|
40
|
+
* All properties and methods bridge to C++ types.
|
|
41
|
+
*/
|
|
42
|
+
public init(_ implementation: any HybridHttpParserSpec) {
|
|
43
|
+
self.__implementation = implementation
|
|
44
|
+
self.__cxxPart = .init()
|
|
45
|
+
/* no base class */
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get the actual `HybridHttpParserSpec` instance this class wraps.
|
|
50
|
+
*/
|
|
51
|
+
@inline(__always)
|
|
52
|
+
public func getHybridHttpParserSpec() -> any HybridHttpParserSpec {
|
|
53
|
+
return __implementation
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
58
|
+
* This acquires one additional strong reference on the object!
|
|
59
|
+
*/
|
|
60
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
61
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Casts an unsafe pointer to a `HybridHttpParserSpec_cxx`.
|
|
66
|
+
* The pointer has to be a retained opaque `Unmanaged<HybridHttpParserSpec_cxx>`.
|
|
67
|
+
* This removes one strong reference from the object!
|
|
68
|
+
*/
|
|
69
|
+
public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridHttpParserSpec_cxx {
|
|
70
|
+
return Unmanaged<HybridHttpParserSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets (or creates) the C++ part of this Hybrid Object.
|
|
75
|
+
* The C++ part is a `std::shared_ptr<HybridHttpParserSpec>`.
|
|
76
|
+
*/
|
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridHttpParserSpec_ {
|
|
78
|
+
let cachedCxxPart = self.__cxxPart.lock()
|
|
79
|
+
if Bool(fromCxx: cachedCxxPart) {
|
|
80
|
+
return cachedCxxPart
|
|
81
|
+
} else {
|
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridHttpParserSpec_(self.toUnsafe())
|
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridHttpParserSpec_(newCxxPart)
|
|
84
|
+
return newCxxPart
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Get the memory size of the Swift class (plus size of any other allocations)
|
|
92
|
+
* so the JS VM can properly track it and garbage-collect the JS object if needed.
|
|
93
|
+
*/
|
|
94
|
+
@inline(__always)
|
|
95
|
+
public var memorySize: Int {
|
|
96
|
+
return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Call dispose() on the Swift class.
|
|
101
|
+
* This _may_ be called manually from JS.
|
|
102
|
+
*/
|
|
103
|
+
@inline(__always)
|
|
104
|
+
public func dispose() {
|
|
105
|
+
self.__implementation.dispose()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Call toString() on the Swift class.
|
|
110
|
+
*/
|
|
111
|
+
@inline(__always)
|
|
112
|
+
public func toString() -> String {
|
|
113
|
+
return self.__implementation.toString()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Properties
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
// Methods
|
|
120
|
+
@inline(__always)
|
|
121
|
+
public final func feed(data: ArrayBuffer) -> bridge.Result_std__string_ {
|
|
122
|
+
do {
|
|
123
|
+
let __result = try self.__implementation.feed(data: data)
|
|
124
|
+
let __resultCpp = std.string(__result)
|
|
125
|
+
return bridge.create_Result_std__string_(__resultCpp)
|
|
126
|
+
} catch (let __error) {
|
|
127
|
+
let __exceptionPtr = __error.toCpp()
|
|
128
|
+
return bridge.create_Result_std__string_(__exceptionPtr)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -16,6 +16,7 @@ public protocol HybridNetDriverSpec_protocol: HybridObject {
|
|
|
16
16
|
// Methods
|
|
17
17
|
func createSocket(id: String?) throws -> (any HybridNetSocketDriverSpec)
|
|
18
18
|
func createServer() throws -> (any HybridNetServerDriverSpec)
|
|
19
|
+
func createHttpParser(mode: Double) throws -> (any HybridHttpParserSpec)
|
|
19
20
|
func createSecureContext(cert: String, key: String, passphrase: String?) throws -> Double
|
|
20
21
|
func createEmptySecureContext() throws -> Double
|
|
21
22
|
func addCACertToSecureContext(scId: Double, ca: String) throws -> Void
|
|
@@ -154,6 +154,21 @@ open class HybridNetDriverSpec_cxx {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
@inline(__always)
|
|
158
|
+
public final func createHttpParser(mode: Double) -> bridge.Result_std__shared_ptr_HybridHttpParserSpec__ {
|
|
159
|
+
do {
|
|
160
|
+
let __result = try self.__implementation.createHttpParser(mode: mode)
|
|
161
|
+
let __resultCpp = { () -> bridge.std__shared_ptr_HybridHttpParserSpec_ in
|
|
162
|
+
let __cxxWrapped = __result.getCxxWrapper()
|
|
163
|
+
return __cxxWrapped.getCxxPart()
|
|
164
|
+
}()
|
|
165
|
+
return bridge.create_Result_std__shared_ptr_HybridHttpParserSpec__(__resultCpp)
|
|
166
|
+
} catch (let __error) {
|
|
167
|
+
let __exceptionPtr = __error.toCpp()
|
|
168
|
+
return bridge.create_Result_std__shared_ptr_HybridHttpParserSpec__(__exceptionPtr)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
157
172
|
@inline(__always)
|
|
158
173
|
public final func createSecureContext(cert: std.string, key: std.string, passphrase: bridge.std__optional_std__string_) -> bridge.Result_double_ {
|
|
159
174
|
do {
|
|
@@ -18,6 +18,7 @@ public protocol HybridNetServerDriverSpec_protocol: HybridObject {
|
|
|
18
18
|
func listen(port: Double, backlog: Double?, ipv6Only: Bool?, reusePort: Bool?) throws -> Void
|
|
19
19
|
func listenTLS(port: Double, secureContextId: Double, backlog: Double?, ipv6Only: Bool?, reusePort: Bool?) throws -> Void
|
|
20
20
|
func listenUnix(path: String, backlog: Double?) throws -> Void
|
|
21
|
+
func listenTLSUnix(path: String, secureContextId: Double, backlog: Double?) throws -> Void
|
|
21
22
|
func listenHandle(fd: Double, backlog: Double?) throws -> Void
|
|
22
23
|
func getLocalAddress() throws -> String
|
|
23
24
|
func close() throws -> Void
|
|
@@ -206,6 +206,17 @@ open class HybridNetServerDriverSpec_cxx {
|
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
@inline(__always)
|
|
210
|
+
public final func listenTLSUnix(path: std.string, secureContextId: Double, backlog: bridge.std__optional_double_) -> bridge.Result_void_ {
|
|
211
|
+
do {
|
|
212
|
+
try self.__implementation.listenTLSUnix(path: String(path), secureContextId: secureContextId, backlog: backlog.value)
|
|
213
|
+
return bridge.create_Result_void_()
|
|
214
|
+
} catch (let __error) {
|
|
215
|
+
let __exceptionPtr = __error.toCpp()
|
|
216
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
209
220
|
@inline(__always)
|
|
210
221
|
public final func listenHandle(fd: Double, backlog: bridge.std__optional_double_) -> bridge.Result_void_ {
|
|
211
222
|
do {
|
|
@@ -39,6 +39,8 @@ public protocol HybridNetSocketDriverSpec_protocol: HybridObject {
|
|
|
39
39
|
func destroy() throws -> Void
|
|
40
40
|
func resetAndDestroy() throws -> Void
|
|
41
41
|
func enableKeylog() throws -> Void
|
|
42
|
+
func enableTrace() throws -> Void
|
|
43
|
+
func exportKeyingMaterial(length: Double, label: String, context: ArrayBuffer?) throws -> ArrayBuffer?
|
|
42
44
|
func setNoDelay(enable: Bool) throws -> Void
|
|
43
45
|
func setKeepAlive(enable: Bool, delay: Double) throws -> Void
|
|
44
46
|
func getLocalAddress() throws -> String
|