@@ -549,11 +549,12 @@ open class NimbusClient:
549
549
return try ! rustCall { uniffi_nimbus_fn_clone_nimbusclient ( self . pointer, $0) }
550
550
}
551
551
552
- public convenience init ( appCtx: AppContext , coenrollingFeatureIds: [ String ] , dbpath: String , remoteSettingsConfig: RemoteSettingsConfig ? , metricsHandler: MetricsHandler ) throws {
552
+ public convenience init ( appCtx: AppContext , recordedContext : RecordedContext ? , coenrollingFeatureIds: [ String ] , dbpath: String , remoteSettingsConfig: RemoteSettingsConfig ? , metricsHandler: MetricsHandler ) throws {
553
553
let pointer =
554
554
try rustCallWithError ( FfiConverterTypeNimbusError . lift) {
555
555
uniffi_nimbus_fn_constructor_nimbusclient_new (
556
556
FfiConverterTypeAppContext . lower ( appCtx) ,
557
+ FfiConverterOptionTypeRecordedContext . lower ( recordedContext) ,
557
558
FfiConverterSequenceString . lower ( coenrollingFeatureIds) ,
558
559
FfiConverterString . lower ( dbpath) ,
559
560
FfiConverterOptionTypeRemoteSettingsConfig . lower ( remoteSettingsConfig) ,
@@ -965,6 +966,175 @@ public func FfiConverterTypeNimbusTargetingHelper_lower(_ value: NimbusTargeting
965
966
return FfiConverterTypeNimbusTargetingHelper . lower ( value)
966
967
}
967
968
969
+ public protocol RecordedContext : AnyObject {
970
+ func record( )
971
+
972
+ func toJson( ) -> JsonObject
973
+ }
974
+
975
+ open class RecordedContextImpl :
976
+ RecordedContext
977
+ {
978
+ fileprivate let pointer : UnsafeMutableRawPointer !
979
+
980
+ /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly.
981
+ public struct NoPointer {
982
+ public init ( ) { }
983
+ }
984
+
985
+ // TODO: We'd like this to be `private` but for Swifty reasons,
986
+ // we can't implement `FfiConverter` without making this `required` and we can't
987
+ // make it `required` without making it `public`.
988
+ public required init ( unsafeFromRawPointer pointer: UnsafeMutableRawPointer ) {
989
+ self . pointer = pointer
990
+ }
991
+
992
+ /// This constructor can be used to instantiate a fake object.
993
+ /// - Parameter noPointer: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
994
+ ///
995
+ /// - Warning:
996
+ /// Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing [Pointer] the FFI lower functions will crash.
997
+ public init ( noPointer _: NoPointer ) {
998
+ pointer = nil
999
+ }
1000
+
1001
+ public func uniffiClonePointer( ) -> UnsafeMutableRawPointer {
1002
+ return try ! rustCall { uniffi_nimbus_fn_clone_recordedcontext ( self . pointer, $0) }
1003
+ }
1004
+
1005
+ // No primary constructor declared for this class.
1006
+
1007
+ deinit {
1008
+ guard let pointer = pointer else {
1009
+ return
1010
+ }
1011
+
1012
+ try ! rustCall { uniffi_nimbus_fn_free_recordedcontext ( pointer, $0) }
1013
+ }
1014
+
1015
+ open func record( ) { try ! rustCall {
1016
+ uniffi_nimbus_fn_method_recordedcontext_record ( self . uniffiClonePointer ( ) , $0)
1017
+ }
1018
+ }
1019
+
1020
+ open func toJson( ) -> JsonObject {
1021
+ return try ! FfiConverterTypeJsonObject . lift ( try ! rustCall {
1022
+ uniffi_nimbus_fn_method_recordedcontext_to_json ( self . uniffiClonePointer ( ) , $0)
1023
+ } )
1024
+ }
1025
+ }
1026
+
1027
+ // Magic number for the Rust proxy to call using the same mechanism as every other method,
1028
+ // to free the callback once it's dropped by Rust.
1029
+ private let IDX_CALLBACK_FREE : Int32 = 0
1030
+ // Callback return codes
1031
+ private let UNIFFI_CALLBACK_SUCCESS : Int32 = 0
1032
+ private let UNIFFI_CALLBACK_ERROR : Int32 = 1
1033
+ private let UNIFFI_CALLBACK_UNEXPECTED_ERROR : Int32 = 2
1034
+
1035
+ // Put the implementation in a struct so we don't pollute the top-level namespace
1036
+ private enum UniffiCallbackInterfaceRecordedContext {
1037
+ // Create the VTable using a series of closures.
1038
+ // Swift automatically converts these into C callback functions.
1039
+ static var vtable : UniffiVTableCallbackInterfaceRecordedContext = . init(
1040
+ record: { (
1041
+ uniffiHandle: UInt64 ,
1042
+ _: UnsafeMutableRawPointer ,
1043
+ uniffiCallStatus: UnsafeMutablePointer < RustCallStatus >
1044
+ ) in
1045
+ let makeCall = {
1046
+ ( ) throws in
1047
+ guard let uniffiObj = try ? FfiConverterTypeRecordedContext . handleMap. get ( handle: uniffiHandle) else {
1048
+ throw UniffiInternalError . unexpectedStaleHandle
1049
+ }
1050
+ return uniffiObj. record (
1051
+ )
1052
+ }
1053
+
1054
+ let writeReturn = { ( ) }
1055
+ uniffiTraitInterfaceCall (
1056
+ callStatus: uniffiCallStatus,
1057
+ makeCall: makeCall,
1058
+ writeReturn: writeReturn
1059
+ )
1060
+ } ,
1061
+ toJson: { (
1062
+ uniffiHandle: UInt64 ,
1063
+ uniffiOutReturn: UnsafeMutablePointer < RustBuffer > ,
1064
+ uniffiCallStatus: UnsafeMutablePointer < RustCallStatus >
1065
+ ) in
1066
+ let makeCall = {
1067
+ ( ) throws -> JsonObject in
1068
+ guard let uniffiObj = try ? FfiConverterTypeRecordedContext . handleMap. get ( handle: uniffiHandle) else {
1069
+ throw UniffiInternalError . unexpectedStaleHandle
1070
+ }
1071
+ return uniffiObj. toJson (
1072
+ )
1073
+ }
1074
+
1075
+ let writeReturn = { uniffiOutReturn. pointee = FfiConverterTypeJsonObject . lower ( $0) }
1076
+ uniffiTraitInterfaceCall (
1077
+ callStatus: uniffiCallStatus,
1078
+ makeCall: makeCall,
1079
+ writeReturn: writeReturn
1080
+ )
1081
+ } ,
1082
+ uniffiFree: { ( uniffiHandle: UInt64 ) in
1083
+ let result = try ? FfiConverterTypeRecordedContext . handleMap. remove ( handle: uniffiHandle)
1084
+ if result == nil {
1085
+ print ( " Uniffi callback interface RecordedContext: handle missing in uniffiFree " )
1086
+ }
1087
+ }
1088
+ )
1089
+ }
1090
+
1091
+ private func uniffiCallbackInitRecordedContext( ) {
1092
+ uniffi_nimbus_fn_init_callback_vtable_recordedcontext ( & UniffiCallbackInterfaceRecordedContext. vtable)
1093
+ }
1094
+
1095
+ public struct FfiConverterTypeRecordedContext : FfiConverter {
1096
+ fileprivate static var handleMap = UniffiHandleMap < RecordedContext > ( )
1097
+
1098
+ typealias FfiType = UnsafeMutableRawPointer
1099
+ typealias SwiftType = RecordedContext
1100
+
1101
+ public static func lift( _ pointer: UnsafeMutableRawPointer ) throws -> RecordedContext {
1102
+ return RecordedContextImpl ( unsafeFromRawPointer: pointer)
1103
+ }
1104
+
1105
+ public static func lower( _ value: RecordedContext ) -> UnsafeMutableRawPointer {
1106
+ guard let ptr = UnsafeMutableRawPointer ( bitPattern: UInt ( truncatingIfNeeded: handleMap. insert ( obj: value) ) ) else {
1107
+ fatalError ( " Cast to UnsafeMutableRawPointer failed " )
1108
+ }
1109
+ return ptr
1110
+ }
1111
+
1112
+ public static func read( from buf: inout ( data: Data , offset: Data . Index ) ) throws -> RecordedContext {
1113
+ let v : UInt64 = try readInt ( & buf)
1114
+ // The Rust code won't compile if a pointer won't fit in a UInt64.
1115
+ // We have to go via `UInt` because that's the thing that's the size of a pointer.
1116
+ let ptr = UnsafeMutableRawPointer ( bitPattern: UInt ( truncatingIfNeeded: v) )
1117
+ if ptr == nil {
1118
+ throw UniffiInternalError . unexpectedNullPointer
1119
+ }
1120
+ return try lift ( ptr!)
1121
+ }
1122
+
1123
+ public static func write( _ value: RecordedContext , into buf: inout [ UInt8 ] ) {
1124
+ // This fiddling is because `Int` is the thing that's the same size as a pointer.
1125
+ // The Rust code won't compile if a pointer won't fit in a `UInt64`.
1126
+ writeInt ( & buf, UInt64 ( bitPattern: Int64 ( Int ( bitPattern: lower ( value) ) ) ) )
1127
+ }
1128
+ }
1129
+
1130
+ public func FfiConverterTypeRecordedContext_lift( _ pointer: UnsafeMutableRawPointer ) throws -> RecordedContext {
1131
+ return try FfiConverterTypeRecordedContext . lift ( pointer)
1132
+ }
1133
+
1134
+ public func FfiConverterTypeRecordedContext_lower( _ value: RecordedContext ) -> UnsafeMutableRawPointer {
1135
+ return FfiConverterTypeRecordedContext . lower ( value)
1136
+ }
1137
+
968
1138
public struct AppContext {
969
1139
public var appName : String
970
1140
public var appId : String
@@ -1906,14 +2076,6 @@ public protocol MetricsHandler: AnyObject {
1906
2076
func recordMalformedFeatureConfig( event: MalformedFeatureConfigExtraDef )
1907
2077
}
1908
2078
1909
- // Magic number for the Rust proxy to call using the same mechanism as every other method,
1910
- // to free the callback once it's dropped by Rust.
1911
- private let IDX_CALLBACK_FREE : Int32 = 0
1912
- // Callback return codes
1913
- private let UNIFFI_CALLBACK_SUCCESS : Int32 = 0
1914
- private let UNIFFI_CALLBACK_ERROR : Int32 = 1
1915
- private let UNIFFI_CALLBACK_UNEXPECTED_ERROR : Int32 = 2
1916
-
1917
2079
// Put the implementation in a struct so we don't pollute the top-level namespace
1918
2080
private enum UniffiCallbackInterfaceMetricsHandler {
1919
2081
// Create the VTable using a series of closures.
@@ -2093,6 +2255,27 @@ private struct FfiConverterOptionString: FfiConverterRustBuffer {
2093
2255
}
2094
2256
}
2095
2257
2258
+ private struct FfiConverterOptionTypeRecordedContext : FfiConverterRustBuffer {
2259
+ typealias SwiftType = RecordedContext ?
2260
+
2261
+ public static func write( _ value: SwiftType , into buf: inout [ UInt8 ] ) {
2262
+ guard let value = value else {
2263
+ writeInt ( & buf, Int8 ( 0 ) )
2264
+ return
2265
+ }
2266
+ writeInt ( & buf, Int8 ( 1 ) )
2267
+ FfiConverterTypeRecordedContext . write ( value, into: & buf)
2268
+ }
2269
+
2270
+ public static func read( from buf: inout ( data: Data , offset: Data . Index ) ) throws -> SwiftType {
2271
+ switch try readInt ( & buf) as Int8 {
2272
+ case 0 : return nil
2273
+ case 1 : return try FfiConverterTypeRecordedContext . read ( from: & buf)
2274
+ default : throw UniffiInternalError . unexpectedOptionalTag
2275
+ }
2276
+ }
2277
+ }
2278
+
2096
2279
private struct FfiConverterOptionTypeRemoteSettingsConfig : FfiConverterRustBuffer {
2097
2280
typealias SwiftType = RemoteSettingsConfig ?
2098
2281
@@ -2401,7 +2584,13 @@ private var initializationResult: InitializationResult {
2401
2584
if uniffi_nimbus_checksum_method_nimbustargetinghelper_eval_jexl ( ) != 42395 {
2402
2585
return InitializationResult . apiChecksumMismatch
2403
2586
}
2404
- if uniffi_nimbus_checksum_constructor_nimbusclient_new ( ) != 55869 {
2587
+ if uniffi_nimbus_checksum_method_recordedcontext_record ( ) != 5916 {
2588
+ return InitializationResult . apiChecksumMismatch
2589
+ }
2590
+ if uniffi_nimbus_checksum_method_recordedcontext_to_json ( ) != 530 {
2591
+ return InitializationResult . apiChecksumMismatch
2592
+ }
2593
+ if uniffi_nimbus_checksum_constructor_nimbusclient_new ( ) != 54745 {
2405
2594
return InitializationResult . apiChecksumMismatch
2406
2595
}
2407
2596
if uniffi_nimbus_checksum_method_metricshandler_record_enrollment_statuses ( ) != 22229 {
@@ -2417,6 +2606,7 @@ private var initializationResult: InitializationResult {
2417
2606
return InitializationResult . apiChecksumMismatch
2418
2607
}
2419
2608
2609
+ uniffiCallbackInitRecordedContext ( )
2420
2610
uniffiCallbackInitMetricsHandler ( )
2421
2611
return InitializationResult . ok
2422
2612
}
0 commit comments