react-native-nitro-net 0.2.0 → 0.3.0
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/Net.nitro.d.ts +19 -0
- package/lib/http.d.ts +203 -0
- package/lib/http.js +1138 -0
- package/lib/https.d.ts +24 -0
- package/lib/https.js +144 -0
- package/lib/index.d.ts +46 -8
- package/lib/index.js +133 -26
- package/lib/tls.d.ts +21 -0
- package/lib/tls.js +74 -4
- 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 +3 -3
- package/src/Net.nitro.ts +17 -0
- package/src/http.ts +1304 -0
- package/src/https.ts +127 -0
- package/src/index.ts +149 -18
- package/src/tls.ts +82 -6
|
@@ -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
|
|
@@ -518,6 +518,42 @@ open class HybridNetSocketDriverSpec_cxx {
|
|
|
518
518
|
}
|
|
519
519
|
}
|
|
520
520
|
|
|
521
|
+
@inline(__always)
|
|
522
|
+
public final func enableTrace() -> bridge.Result_void_ {
|
|
523
|
+
do {
|
|
524
|
+
try self.__implementation.enableTrace()
|
|
525
|
+
return bridge.create_Result_void_()
|
|
526
|
+
} catch (let __error) {
|
|
527
|
+
let __exceptionPtr = __error.toCpp()
|
|
528
|
+
return bridge.create_Result_void_(__exceptionPtr)
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
@inline(__always)
|
|
533
|
+
public final func exportKeyingMaterial(length: Double, label: std.string, context: bridge.std__optional_std__shared_ptr_ArrayBuffer__) -> bridge.Result_std__optional_std__shared_ptr_ArrayBuffer___ {
|
|
534
|
+
do {
|
|
535
|
+
let __result = try self.__implementation.exportKeyingMaterial(length: length, label: String(label), context: { () -> ArrayBuffer? in
|
|
536
|
+
if bridge.has_value_std__optional_std__shared_ptr_ArrayBuffer__(context) {
|
|
537
|
+
let __unwrapped = bridge.get_std__optional_std__shared_ptr_ArrayBuffer__(context)
|
|
538
|
+
return ArrayBuffer(__unwrapped)
|
|
539
|
+
} else {
|
|
540
|
+
return nil
|
|
541
|
+
}
|
|
542
|
+
}())
|
|
543
|
+
let __resultCpp = { () -> bridge.std__optional_std__shared_ptr_ArrayBuffer__ in
|
|
544
|
+
if let __unwrappedValue = __result {
|
|
545
|
+
return bridge.create_std__optional_std__shared_ptr_ArrayBuffer__(__unwrappedValue.getArrayBuffer())
|
|
546
|
+
} else {
|
|
547
|
+
return .init()
|
|
548
|
+
}
|
|
549
|
+
}()
|
|
550
|
+
return bridge.create_Result_std__optional_std__shared_ptr_ArrayBuffer___(__resultCpp)
|
|
551
|
+
} catch (let __error) {
|
|
552
|
+
let __exceptionPtr = __error.toCpp()
|
|
553
|
+
return bridge.create_Result_std__optional_std__shared_ptr_ArrayBuffer___(__exceptionPtr)
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
521
557
|
@inline(__always)
|
|
522
558
|
public final func setNoDelay(enable: Bool) -> bridge.Result_void_ {
|
|
523
559
|
do {
|
|
@@ -19,13 +19,19 @@ public extension NetConfig {
|
|
|
19
19
|
/**
|
|
20
20
|
* Create a new instance of `NetConfig`.
|
|
21
21
|
*/
|
|
22
|
-
init(workerThreads: Double?) {
|
|
22
|
+
init(workerThreads: Double?, debug: Bool?) {
|
|
23
23
|
self.init({ () -> bridge.std__optional_double_ in
|
|
24
24
|
if let __unwrappedValue = workerThreads {
|
|
25
25
|
return bridge.create_std__optional_double_(__unwrappedValue)
|
|
26
26
|
} else {
|
|
27
27
|
return .init()
|
|
28
28
|
}
|
|
29
|
+
}(), { () -> bridge.std__optional_bool_ in
|
|
30
|
+
if let __unwrappedValue = debug {
|
|
31
|
+
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
32
|
+
} else {
|
|
33
|
+
return .init()
|
|
34
|
+
}
|
|
29
35
|
}())
|
|
30
36
|
}
|
|
31
37
|
|
|
@@ -33,4 +39,16 @@ public extension NetConfig {
|
|
|
33
39
|
var workerThreads: Double? {
|
|
34
40
|
return self.__workerThreads.value
|
|
35
41
|
}
|
|
42
|
+
|
|
43
|
+
@inline(__always)
|
|
44
|
+
var debug: Bool? {
|
|
45
|
+
return { () -> Bool? in
|
|
46
|
+
if bridge.has_value_std__optional_bool_(self.__debug) {
|
|
47
|
+
let __unwrapped = bridge.get_std__optional_bool_(self.__debug)
|
|
48
|
+
return __unwrapped
|
|
49
|
+
} else {
|
|
50
|
+
return nil
|
|
51
|
+
}
|
|
52
|
+
}()
|
|
53
|
+
}
|
|
36
54
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridHttpParserSpec.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 "HybridHttpParserSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::net {
|
|
11
|
+
|
|
12
|
+
void HybridHttpParserSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("feed", &HybridHttpParserSpec::feed);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
} // namespace margelo::nitro::net
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridHttpParserSpec.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
|
+
#if __has_include(<NitroModules/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#include <string>
|
|
19
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
20
|
+
|
|
21
|
+
namespace margelo::nitro::net {
|
|
22
|
+
|
|
23
|
+
using namespace margelo::nitro;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* An abstract base class for `HttpParser`
|
|
27
|
+
* Inherit this class to create instances of `HybridHttpParserSpec` in C++.
|
|
28
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
29
|
+
* @example
|
|
30
|
+
* ```cpp
|
|
31
|
+
* class HybridHttpParser: public HybridHttpParserSpec {
|
|
32
|
+
* public:
|
|
33
|
+
* HybridHttpParser(...): HybridObject(TAG) { ... }
|
|
34
|
+
* // ...
|
|
35
|
+
* };
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
class HybridHttpParserSpec: public virtual HybridObject {
|
|
39
|
+
public:
|
|
40
|
+
// Constructor
|
|
41
|
+
explicit HybridHttpParserSpec(): HybridObject(TAG) { }
|
|
42
|
+
|
|
43
|
+
// Destructor
|
|
44
|
+
~HybridHttpParserSpec() override = default;
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
// Properties
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
public:
|
|
51
|
+
// Methods
|
|
52
|
+
virtual std::string feed(const std::shared_ptr<ArrayBuffer>& data) = 0;
|
|
53
|
+
|
|
54
|
+
protected:
|
|
55
|
+
// Hybrid Setup
|
|
56
|
+
void loadHybridMethods() override;
|
|
57
|
+
|
|
58
|
+
protected:
|
|
59
|
+
// Tag for logging
|
|
60
|
+
static constexpr auto TAG = "HttpParser";
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
} // namespace margelo::nitro::net
|
|
@@ -16,6 +16,7 @@ namespace margelo::nitro::net {
|
|
|
16
16
|
registerHybrids(this, [](Prototype& prototype) {
|
|
17
17
|
prototype.registerHybridMethod("createSocket", &HybridNetDriverSpec::createSocket);
|
|
18
18
|
prototype.registerHybridMethod("createServer", &HybridNetDriverSpec::createServer);
|
|
19
|
+
prototype.registerHybridMethod("createHttpParser", &HybridNetDriverSpec::createHttpParser);
|
|
19
20
|
prototype.registerHybridMethod("createSecureContext", &HybridNetDriverSpec::createSecureContext);
|
|
20
21
|
prototype.registerHybridMethod("createEmptySecureContext", &HybridNetDriverSpec::createEmptySecureContext);
|
|
21
22
|
prototype.registerHybridMethod("addCACertToSecureContext", &HybridNetDriverSpec::addCACertToSecureContext);
|
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
namespace margelo::nitro::net { class HybridNetSocketDriverSpec; }
|
|
18
18
|
// Forward declaration of `HybridNetServerDriverSpec` to properly resolve imports.
|
|
19
19
|
namespace margelo::nitro::net { class HybridNetServerDriverSpec; }
|
|
20
|
+
// Forward declaration of `HybridHttpParserSpec` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::net { class HybridHttpParserSpec; }
|
|
20
22
|
// Forward declaration of `NetConfig` to properly resolve imports.
|
|
21
23
|
namespace margelo::nitro::net { struct NetConfig; }
|
|
22
24
|
|
|
@@ -25,6 +27,7 @@ namespace margelo::nitro::net { struct NetConfig; }
|
|
|
25
27
|
#include <string>
|
|
26
28
|
#include <optional>
|
|
27
29
|
#include "HybridNetServerDriverSpec.hpp"
|
|
30
|
+
#include "HybridHttpParserSpec.hpp"
|
|
28
31
|
#include <NitroModules/ArrayBuffer.hpp>
|
|
29
32
|
#include "NetConfig.hpp"
|
|
30
33
|
|
|
@@ -61,6 +64,7 @@ namespace margelo::nitro::net {
|
|
|
61
64
|
// Methods
|
|
62
65
|
virtual std::shared_ptr<HybridNetSocketDriverSpec> createSocket(const std::optional<std::string>& id) = 0;
|
|
63
66
|
virtual std::shared_ptr<HybridNetServerDriverSpec> createServer() = 0;
|
|
67
|
+
virtual std::shared_ptr<HybridHttpParserSpec> createHttpParser(double mode) = 0;
|
|
64
68
|
virtual double createSecureContext(const std::string& cert, const std::string& key, const std::optional<std::string>& passphrase) = 0;
|
|
65
69
|
virtual double createEmptySecureContext() = 0;
|
|
66
70
|
virtual void addCACertToSecureContext(double scId, const std::string& ca) = 0;
|
|
@@ -21,6 +21,7 @@ namespace margelo::nitro::net {
|
|
|
21
21
|
prototype.registerHybridMethod("listen", &HybridNetServerDriverSpec::listen);
|
|
22
22
|
prototype.registerHybridMethod("listenTLS", &HybridNetServerDriverSpec::listenTLS);
|
|
23
23
|
prototype.registerHybridMethod("listenUnix", &HybridNetServerDriverSpec::listenUnix);
|
|
24
|
+
prototype.registerHybridMethod("listenTLSUnix", &HybridNetServerDriverSpec::listenTLSUnix);
|
|
24
25
|
prototype.registerHybridMethod("listenHandle", &HybridNetServerDriverSpec::listenHandle);
|
|
25
26
|
prototype.registerHybridMethod("getLocalAddress", &HybridNetServerDriverSpec::getLocalAddress);
|
|
26
27
|
prototype.registerHybridMethod("close", &HybridNetServerDriverSpec::close);
|
|
@@ -57,6 +57,7 @@ namespace margelo::nitro::net {
|
|
|
57
57
|
virtual void listen(double port, std::optional<double> backlog, std::optional<bool> ipv6Only, std::optional<bool> reusePort) = 0;
|
|
58
58
|
virtual void listenTLS(double port, double secureContextId, std::optional<double> backlog, std::optional<bool> ipv6Only, std::optional<bool> reusePort) = 0;
|
|
59
59
|
virtual void listenUnix(const std::string& path, std::optional<double> backlog) = 0;
|
|
60
|
+
virtual void listenTLSUnix(const std::string& path, double secureContextId, std::optional<double> backlog) = 0;
|
|
60
61
|
virtual void listenHandle(double fd, std::optional<double> backlog) = 0;
|
|
61
62
|
virtual std::string getLocalAddress() = 0;
|
|
62
63
|
virtual void close() = 0;
|
|
@@ -41,6 +41,8 @@ namespace margelo::nitro::net {
|
|
|
41
41
|
prototype.registerHybridMethod("destroy", &HybridNetSocketDriverSpec::destroy);
|
|
42
42
|
prototype.registerHybridMethod("resetAndDestroy", &HybridNetSocketDriverSpec::resetAndDestroy);
|
|
43
43
|
prototype.registerHybridMethod("enableKeylog", &HybridNetSocketDriverSpec::enableKeylog);
|
|
44
|
+
prototype.registerHybridMethod("enableTrace", &HybridNetSocketDriverSpec::enableTrace);
|
|
45
|
+
prototype.registerHybridMethod("exportKeyingMaterial", &HybridNetSocketDriverSpec::exportKeyingMaterial);
|
|
44
46
|
prototype.registerHybridMethod("setNoDelay", &HybridNetSocketDriverSpec::setNoDelay);
|
|
45
47
|
prototype.registerHybridMethod("setKeepAlive", &HybridNetSocketDriverSpec::setKeepAlive);
|
|
46
48
|
prototype.registerHybridMethod("getLocalAddress", &HybridNetSocketDriverSpec::getLocalAddress);
|
|
@@ -77,6 +77,8 @@ namespace margelo::nitro::net {
|
|
|
77
77
|
virtual void destroy() = 0;
|
|
78
78
|
virtual void resetAndDestroy() = 0;
|
|
79
79
|
virtual void enableKeylog() = 0;
|
|
80
|
+
virtual void enableTrace() = 0;
|
|
81
|
+
virtual std::optional<std::shared_ptr<ArrayBuffer>> exportKeyingMaterial(double length, const std::string& label, const std::optional<std::shared_ptr<ArrayBuffer>>& context) = 0;
|
|
80
82
|
virtual void setNoDelay(bool enable) = 0;
|
|
81
83
|
virtual void setKeepAlive(bool enable, double delay) = 0;
|
|
82
84
|
virtual std::string getLocalAddress() = 0;
|