@@ -281,7 +281,7 @@ private func makeRustCall<T, E: Swift.Error>(
281
281
_ callback: ( UnsafeMutablePointer < RustCallStatus > ) -> T ,
282
282
errorHandler: ( ( RustBuffer ) throws -> E ) ?
283
283
) throws -> T {
284
- uniffiEnsureInitialized ( )
284
+ uniffiEnsureAsOhttpClientInitialized ( )
285
285
var callStatus = RustCallStatus . init ( )
286
286
let returnedVal = callback ( & callStatus)
287
287
try uniffiCheckCallStatus ( callStatus: callStatus, errorHandler: errorHandler)
@@ -352,9 +352,10 @@ private func uniffiTraitInterfaceCallWithError<T, E>(
352
352
callStatus. pointee. errorBuf = FfiConverterString . lower ( String ( describing: error) )
353
353
}
354
354
}
355
- fileprivate class UniffiHandleMap < T> {
356
- private var map : [ UInt64 : T ] = [ : ]
355
+ fileprivate final class UniffiHandleMap < T> : @ unchecked Sendable {
356
+ // All mutation happens with this lock held, which is why we implement @unchecked Sendable.
357
357
private let lock = NSLock ( )
358
+ private var map : [ UInt64 : T ] = [ : ]
358
359
private var currentHandle : UInt64 = 1
359
360
360
361
func insert( obj: T ) -> UInt64 {
@@ -392,6 +393,7 @@ fileprivate class UniffiHandleMap<T> {
392
393
}
393
394
}
394
395
396
+
395
397
// Public interface members begin here.
396
398
397
399
@@ -475,7 +477,7 @@ fileprivate struct FfiConverterString: FfiConverter {
475
477
* Each OHTTP request-reply exchange needs to create an OhttpSession
476
478
* object to manage encryption state.
477
479
*/
478
- public protocol OhttpSessionProtocol : AnyObject {
480
+ public protocol OhttpSessionProtocol : AnyObject {
479
481
480
482
/**
481
483
* Decypt and unpack the response from the Relay for the previously
@@ -496,8 +498,7 @@ public protocol OhttpSessionProtocol : AnyObject {
496
498
* Each OHTTP request-reply exchange needs to create an OhttpSession
497
499
* object to manage encryption state.
498
500
*/
499
- open class OhttpSession :
500
- OhttpSessionProtocol {
501
+ open class OhttpSession : OhttpSessionProtocol , @unchecked Sendable {
501
502
fileprivate let pointer : UnsafeMutableRawPointer !
502
503
503
504
/// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly.
@@ -538,7 +539,7 @@ open class OhttpSession:
538
539
*/
539
540
public convenience init ( config: [ UInt8 ] ) throws {
540
541
let pointer =
541
- try rustCallWithError ( FfiConverterTypeOhttpError . lift ) {
542
+ try rustCallWithError ( FfiConverterTypeOhttpError_lift ) {
542
543
uniffi_as_ohttp_client_fn_constructor_ohttpsession_new (
543
544
FfiConverterSequenceUInt8 . lower ( config) , $0
544
545
)
@@ -562,8 +563,8 @@ public convenience init(config: [UInt8])throws {
562
563
* encapsulated request. You must use the same OhttpSession that
563
564
* generated the request message.
564
565
*/
565
- open func decapsulate( encoded: [ UInt8 ] ) throws -> OhttpResponse {
566
- return try FfiConverterTypeOhttpResponse . lift ( try rustCallWithError ( FfiConverterTypeOhttpError . lift ) {
566
+ open func decapsulate( encoded: [ UInt8 ] ) throws -> OhttpResponse {
567
+ return try FfiConverterTypeOhttpResponse_lift ( try rustCallWithError ( FfiConverterTypeOhttpError_lift ) {
567
568
uniffi_as_ohttp_client_fn_method_ohttpsession_decapsulate ( self . uniffiClonePointer ( ) ,
568
569
FfiConverterSequenceUInt8 . lower ( encoded) , $0
569
570
)
@@ -575,8 +576,8 @@ open func decapsulate(encoded: [UInt8])throws -> OhttpResponse {
575
576
* payload using HPKE. The caller is responsible for sending the
576
577
* resulting message to the Relay.
577
578
*/
578
- open func encapsulate( method: String , scheme: String , server: String , endpoint: String , headers: [ String : String ] , payload: [ UInt8 ] ) throws -> [ UInt8 ] {
579
- return try FfiConverterSequenceUInt8 . lift ( try rustCallWithError ( FfiConverterTypeOhttpError . lift ) {
579
+ open func encapsulate( method: String , scheme: String , server: String , endpoint: String , headers: [ String : String ] , payload: [ UInt8 ] ) throws -> [ UInt8 ] {
580
+ return try FfiConverterSequenceUInt8 . lift ( try rustCallWithError ( FfiConverterTypeOhttpError_lift ) {
580
581
uniffi_as_ohttp_client_fn_method_ohttpsession_encapsulate ( self . uniffiClonePointer ( ) ,
581
582
FfiConverterString . lower ( method) ,
582
583
FfiConverterString . lower ( scheme) ,
@@ -591,6 +592,7 @@ open func encapsulate(method: String, scheme: String, server: String, endpoint:
591
592
592
593
}
593
594
595
+
594
596
#if swift(>=5.8)
595
597
@_documentation ( visibility: private)
596
598
#endif
@@ -626,8 +628,6 @@ public struct FfiConverterTypeOhttpSession: FfiConverter {
626
628
}
627
629
628
630
629
-
630
-
631
631
#if swift(>=5.8)
632
632
@_documentation ( visibility: private)
633
633
#endif
@@ -645,11 +645,13 @@ public func FfiConverterTypeOhttpSession_lower(_ value: OhttpSession) -> UnsafeM
645
645
646
646
647
647
648
+
649
+
648
650
/**
649
651
* A testing interface for decrypting and responding to OHTTP messages. This
650
652
* should only be used for testing.
651
653
*/
652
- public protocol OhttpTestServerProtocol : AnyObject {
654
+ public protocol OhttpTestServerProtocol : AnyObject {
653
655
654
656
/**
655
657
* Return the unique encryption key config for this instance of test server.
@@ -665,8 +667,7 @@ public protocol OhttpTestServerProtocol : AnyObject {
665
667
* A testing interface for decrypting and responding to OHTTP messages. This
666
668
* should only be used for testing.
667
669
*/
668
- open class OhttpTestServer :
669
- OhttpTestServerProtocol {
670
+ open class OhttpTestServer : OhttpTestServerProtocol , @unchecked Sendable {
670
671
fileprivate let pointer : UnsafeMutableRawPointer !
671
672
672
673
/// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly.
@@ -725,32 +726,33 @@ public convenience init() {
725
726
/**
726
727
* Return the unique encryption key config for this instance of test server.
727
728
*/
728
- open func getConfig( ) -> [ UInt8 ] {
729
+ open func getConfig( ) -> [ UInt8 ] {
729
730
return try ! FfiConverterSequenceUInt8 . lift ( try ! rustCall ( ) {
730
731
uniffi_as_ohttp_client_fn_method_ohttptestserver_get_config ( self . uniffiClonePointer ( ) , $0
731
732
)
732
733
} )
733
734
}
734
735
735
- open func receive( message: [ UInt8 ] ) throws -> TestServerRequest {
736
- return try FfiConverterTypeTestServerRequest . lift ( try rustCallWithError ( FfiConverterTypeOhttpError . lift ) {
736
+ open func receive( message: [ UInt8 ] ) throws -> TestServerRequest {
737
+ return try FfiConverterTypeTestServerRequest_lift ( try rustCallWithError ( FfiConverterTypeOhttpError_lift ) {
737
738
uniffi_as_ohttp_client_fn_method_ohttptestserver_receive ( self . uniffiClonePointer ( ) ,
738
739
FfiConverterSequenceUInt8 . lower ( message) , $0
739
740
)
740
741
} )
741
742
}
742
743
743
- open func respond( response: OhttpResponse ) throws -> [ UInt8 ] {
744
- return try FfiConverterSequenceUInt8 . lift ( try rustCallWithError ( FfiConverterTypeOhttpError . lift ) {
744
+ open func respond( response: OhttpResponse ) throws -> [ UInt8 ] {
745
+ return try FfiConverterSequenceUInt8 . lift ( try rustCallWithError ( FfiConverterTypeOhttpError_lift ) {
745
746
uniffi_as_ohttp_client_fn_method_ohttptestserver_respond ( self . uniffiClonePointer ( ) ,
746
- FfiConverterTypeOhttpResponse . lower ( response) , $0
747
+ FfiConverterTypeOhttpResponse_lower ( response) , $0
747
748
)
748
749
} )
749
750
}
750
751
751
752
752
753
}
753
754
755
+
754
756
#if swift(>=5.8)
755
757
@_documentation ( visibility: private)
756
758
#endif
@@ -786,8 +788,6 @@ public struct FfiConverterTypeOhttpTestServer: FfiConverter {
786
788
}
787
789
788
790
789
-
790
-
791
791
#if swift(>=5.8)
792
792
@_documentation ( visibility: private)
793
793
#endif
@@ -803,6 +803,8 @@ public func FfiConverterTypeOhttpTestServer_lower(_ value: OhttpTestServer) -> U
803
803
}
804
804
805
805
806
+
807
+
806
808
/**
807
809
* The decrypted response from the Gateway/Target
808
810
*/
@@ -820,6 +822,9 @@ public struct OhttpResponse {
820
822
}
821
823
}
822
824
825
+ #if compiler(>=6)
826
+ extension OhttpResponse : Sendable { }
827
+ #endif
823
828
824
829
825
830
extension OhttpResponse : Equatable , Hashable {
@@ -844,6 +849,7 @@ extension OhttpResponse: Equatable, Hashable {
844
849
}
845
850
846
851
852
+
847
853
#if swift(>=5.8)
848
854
@_documentation ( visibility: private)
849
855
#endif
@@ -900,6 +906,9 @@ public struct TestServerRequest {
900
906
}
901
907
}
902
908
909
+ #if compiler(>=6)
910
+ extension TestServerRequest : Sendable { }
911
+ #endif
903
912
904
913
905
914
extension TestServerRequest : Equatable , Hashable {
@@ -936,6 +945,7 @@ extension TestServerRequest: Equatable, Hashable {
936
945
}
937
946
938
947
948
+
939
949
#if swift(>=5.8)
940
950
@_documentation ( visibility: private)
941
951
#endif
@@ -1080,14 +1090,32 @@ public struct FfiConverterTypeOhttpError: FfiConverterRustBuffer {
1080
1090
}
1081
1091
1082
1092
1093
+ #if swift(>=5.8)
1094
+ @_documentation ( visibility: private)
1095
+ #endif
1096
+ public func FfiConverterTypeOhttpError_lift( _ buf: RustBuffer ) throws -> OhttpError {
1097
+ return try FfiConverterTypeOhttpError . lift ( buf)
1098
+ }
1099
+
1100
+ #if swift(>=5.8)
1101
+ @_documentation ( visibility: private)
1102
+ #endif
1103
+ public func FfiConverterTypeOhttpError_lower( _ value: OhttpError ) -> RustBuffer {
1104
+ return FfiConverterTypeOhttpError . lower ( value)
1105
+ }
1106
+
1107
+
1083
1108
extension OhttpError : Equatable , Hashable { }
1084
1109
1110
+
1111
+
1085
1112
extension OhttpError : Foundation . LocalizedError {
1086
1113
public var errorDescription : String ? {
1087
1114
String ( reflecting: self )
1088
1115
}
1089
1116
}
1090
1117
1118
+
1091
1119
#if swift(>=5.8)
1092
1120
@_documentation ( visibility: private)
1093
1121
#endif
@@ -1146,9 +1174,9 @@ private enum InitializationResult {
1146
1174
}
1147
1175
// Use a global variable to perform the versioning checks. Swift ensures that
1148
1176
// the code inside is only computed once.
1149
- private var initializationResult : InitializationResult = {
1177
+ private let initializationResult : InitializationResult = {
1150
1178
// Get the bindings contract version from our ComponentInterface
1151
- let bindings_contract_version = 26
1179
+ let bindings_contract_version = 29
1152
1180
// Get the scaffolding contract version by calling the into the dylib
1153
1181
let scaffolding_contract_version = ffi_as_ohttp_client_uniffi_contract_version ( )
1154
1182
if bindings_contract_version != scaffolding_contract_version {
@@ -1169,17 +1197,19 @@ private var initializationResult: InitializationResult = {
1169
1197
if ( uniffi_as_ohttp_client_checksum_method_ohttptestserver_respond ( ) != 21845 ) {
1170
1198
return InitializationResult . apiChecksumMismatch
1171
1199
}
1172
- if ( uniffi_as_ohttp_client_checksum_constructor_ohttpsession_new ( ) != 63666 ) {
1200
+ if ( uniffi_as_ohttp_client_checksum_constructor_ohttpsession_new ( ) != 12377 ) {
1173
1201
return InitializationResult . apiChecksumMismatch
1174
1202
}
1175
- if ( uniffi_as_ohttp_client_checksum_constructor_ohttptestserver_new ( ) != 42944 ) {
1203
+ if ( uniffi_as_ohttp_client_checksum_constructor_ohttptestserver_new ( ) != 10284 ) {
1176
1204
return InitializationResult . apiChecksumMismatch
1177
1205
}
1178
1206
1179
1207
return InitializationResult . ok
1180
1208
} ( )
1181
1209
1182
- private func uniffiEnsureInitialized( ) {
1210
+ // Make the ensure init function public so that other modules which have external type references to
1211
+ // our types can call it.
1212
+ public func uniffiEnsureAsOhttpClientInitialized( ) {
1183
1213
switch initializationResult {
1184
1214
case . ok:
1185
1215
break
0 commit comments