diff --git a/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Generated/nimbus.swift b/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Generated/nimbus.swift index 73922e2a8ccbc..d534cce70eef4 100644 --- a/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Generated/nimbus.swift +++ b/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Generated/nimbus.swift @@ -770,7 +770,7 @@ open class NimbusClient: NimbusClientProtocol, @unchecked Sendable { public func uniffiCloneHandle() -> UInt64 { return try! rustCall { uniffi_nimbus_fn_clone_nimbusclient(self.handle, $0) } } -public convenience init(appCtx: AppContext, recordedContext: RecordedContext?, coenrollingFeatureIds: [String], dbpath: String, metricsHandler: MetricsHandler, geckoPrefHandler: GeckoPrefHandler?, remoteSettingsService: RemoteSettingsService?, collectionName: String?)throws { +public convenience init(appCtx: AppContext, recordedContext: RecordedContext?, coenrollingFeatureIds: [String], dbpath: String, metricsHandler: MetricsHandler, geckoPrefHandler: GeckoPrefHandler?, remoteSettingsInfo: NimbusServerSettings?)throws { let handle = try rustCallWithError(FfiConverterTypeNimbusError_lift) { uniffi_nimbus_fn_constructor_nimbusclient_new( @@ -780,8 +780,7 @@ public convenience init(appCtx: AppContext, recordedContext: RecordedContext?, c FfiConverterString.lower(dbpath), FfiConverterCallbackInterfaceMetricsHandler_lower(metricsHandler), FfiConverterOptionCallbackInterfaceGeckoPrefHandler.lower(geckoPrefHandler), - FfiConverterOptionTypeRemoteSettingsService.lower(remoteSettingsService), - FfiConverterOptionString.lower(collectionName),$0 + FfiConverterOptionTypeNimbusServerSettings.lower(remoteSettingsInfo),$0 ) } self.init(unsafeFromHandle: handle) @@ -2532,6 +2531,60 @@ public func FfiConverterTypeMalformedFeatureConfigExtraDef_lower(_ value: Malfor } +public struct NimbusServerSettings { + public var rsService: RemoteSettingsService + public var collectionName: String + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(rsService: RemoteSettingsService, collectionName: String) { + self.rsService = rsService + self.collectionName = collectionName + } + + + + +} + +#if compiler(>=6) +extension NimbusServerSettings: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeNimbusServerSettings: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NimbusServerSettings { + return + try NimbusServerSettings( + rsService: FfiConverterTypeRemoteSettingsService.read(from: &buf), + collectionName: FfiConverterString.read(from: &buf) + ) + } + + public static func write(_ value: NimbusServerSettings, into buf: inout [UInt8]) { + FfiConverterTypeRemoteSettingsService.write(value.rsService, into: &buf) + FfiConverterString.write(value.collectionName, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeNimbusServerSettings_lift(_ buf: RustBuffer) throws -> NimbusServerSettings { + return try FfiConverterTypeNimbusServerSettings.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeNimbusServerSettings_lower(_ value: NimbusServerSettings) -> RustBuffer { + return FfiConverterTypeNimbusServerSettings.lower(value) +} + + public struct OriginalGeckoPref: Equatable, Hashable { public var pref: String public var branch: PrefBranch @@ -3684,8 +3737,8 @@ fileprivate struct FfiConverterOptionTypeRecordedContext: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeRemoteSettingsService: FfiConverterRustBuffer { - typealias SwiftType = RemoteSettingsService? +fileprivate struct FfiConverterOptionTypeNimbusServerSettings: FfiConverterRustBuffer { + typealias SwiftType = NimbusServerSettings? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -3693,13 +3746,13 @@ fileprivate struct FfiConverterOptionTypeRemoteSettingsService: FfiConverterRust return } writeInt(&buf, Int8(1)) - FfiConverterTypeRemoteSettingsService.write(value, into: &buf) + FfiConverterTypeNimbusServerSettings.write(value, into: &buf) } public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { switch try readInt(&buf) as Int8 { case 0: return nil - case 1: return try FfiConverterTypeRemoteSettingsService.read(from: &buf) + case 1: return try FfiConverterTypeNimbusServerSettings.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -4403,7 +4456,7 @@ private let initializationResult: InitializationResult = { if (uniffi_nimbus_checksum_method_recordedcontext_to_json() != 52035) { return InitializationResult.apiChecksumMismatch } - if (uniffi_nimbus_checksum_constructor_nimbusclient_new() != 28763) { + if (uniffi_nimbus_checksum_constructor_nimbusclient_new() != 32755) { return InitializationResult.apiChecksumMismatch } if (uniffi_nimbus_checksum_method_geckoprefhandler_get_prefs_with_state() != 27063) { diff --git a/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Nimbus/NimbusApi.swift b/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Nimbus/NimbusApi.swift index 0589720b7115b..109ef9606f757 100644 --- a/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Nimbus/NimbusApi.swift +++ b/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Nimbus/NimbusApi.swift @@ -234,18 +234,6 @@ public extension Notification.Name { static let nimbusExperimentsApplied = Notification.Name("nimbusExperimentsApplied") } -/// This struct is used during in the `create` method to point `Nimbus` at the given `RemoteSettings` server. -/// -public struct NimbusServerSettings { - public init(url: URL, collection: String = remoteSettingsCollection) { - self.url = url - self.collection = collection - } - - public let url: URL - public let collection: String -} - public let remoteSettingsCollection = "nimbus-mobile-experiments" public let remoteSettingsPreviewCollection = "nimbus-preview" diff --git a/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Nimbus/NimbusBuilder.swift b/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Nimbus/NimbusBuilder.swift index 060503f0b3d0f..a4b6ea0912dcc 100644 --- a/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Nimbus/NimbusBuilder.swift +++ b/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Nimbus/NimbusBuilder.swift @@ -191,23 +191,11 @@ public class NimbusBuilder { appInfo: NimbusAppSettings, remoteSettingsService: RemoteSettingsService? = nil ) -> NimbusInterface { - let serverSettings: NimbusServerSettings? - if let string = url, - let url = URL(string: string) - { - if usePreviewCollection { - serverSettings = NimbusServerSettings(url: url, collection: remoteSettingsPreviewCollection) - } else { - serverSettings = NimbusServerSettings(url: url, collection: remoteSettingsCollection) - } - } else { - serverSettings = nil - } do { let nimbus = try newNimbus( appInfo, - serverSettings: serverSettings, + serverSettings: nil, remoteSettingsService: remoteSettingsService ) let fm = featureManifest @@ -234,7 +222,7 @@ public class NimbusBuilder { // Is the app being built locally, and the nimbus-cli // hasn't been used before this run. func isLocalBuild() -> Bool { - serverSettings == nil && nimbus.isFetchEnabled() + nimbus.isFetchEnabled() } if let args = ArgumentProcessor.createCommandLineArgs(args: commandLineArgs) { @@ -271,16 +259,14 @@ public class NimbusBuilder { serverSettings: NimbusServerSettings?, remoteSettingsService: RemoteSettingsService? ) throws -> NimbusInterface { - try Nimbus.create(serverSettings, + try Nimbus.create(server: serverSettings, appSettings: appInfo, coenrollingFeatureIds: getCoenrollingFeatureIds(), dbPath: dbFilePath, resourceBundles: resourceBundles, userDefaults: userDefaults, errorReporter: errorReporter, - recordedContext: recordedContext, - remoteSettingsService: remoteSettingsService, - collectionName: serverSettings?.collection) + recordedContext: recordedContext) } func newNimbusDisabled() -> NimbusInterface { diff --git a/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Nimbus/NimbusCreate.swift b/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Nimbus/NimbusCreate.swift index 01cbc187f368c..efa0734006519 100644 --- a/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Nimbus/NimbusCreate.swift +++ b/MozillaRustComponents/Sources/FocusRustComponentsWrapper/Nimbus/NimbusCreate.swift @@ -77,7 +77,7 @@ public extension Nimbus { /// - Throws `NimbusError` if anything goes wrong with the Rust FFI or in the `NimbusClient` constructor. /// static func create( - _ server: NimbusServerSettings?, + server: NimbusServerSettings?, appSettings: NimbusAppSettings, coenrollingFeatureIds: [String] = [], dbPath: String, @@ -94,12 +94,7 @@ public extension Nimbus { } let context = Nimbus.buildExperimentContext(appSettings) - let remoteSettings = server.map { server -> RemoteSettingsConfig in - RemoteSettingsConfig( - collectionName: server.collection, - server: .custom(url: server.url.absoluteString) - ) - } + let nimbusClient = try NimbusClient( appCtx: context, recordedContext: recordedContext, @@ -107,8 +102,7 @@ public extension Nimbus { dbpath: dbPath, metricsHandler: GleanMetricsHandler(), geckoPrefHandler: nil, - remoteSettingsService: remoteSettingsService, - collectionName: collectionName + remoteSettingsInfo: server, ) return Nimbus( diff --git a/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Generated/nimbus.swift b/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Generated/nimbus.swift index 73922e2a8ccbc..d534cce70eef4 100644 --- a/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Generated/nimbus.swift +++ b/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Generated/nimbus.swift @@ -770,7 +770,7 @@ open class NimbusClient: NimbusClientProtocol, @unchecked Sendable { public func uniffiCloneHandle() -> UInt64 { return try! rustCall { uniffi_nimbus_fn_clone_nimbusclient(self.handle, $0) } } -public convenience init(appCtx: AppContext, recordedContext: RecordedContext?, coenrollingFeatureIds: [String], dbpath: String, metricsHandler: MetricsHandler, geckoPrefHandler: GeckoPrefHandler?, remoteSettingsService: RemoteSettingsService?, collectionName: String?)throws { +public convenience init(appCtx: AppContext, recordedContext: RecordedContext?, coenrollingFeatureIds: [String], dbpath: String, metricsHandler: MetricsHandler, geckoPrefHandler: GeckoPrefHandler?, remoteSettingsInfo: NimbusServerSettings?)throws { let handle = try rustCallWithError(FfiConverterTypeNimbusError_lift) { uniffi_nimbus_fn_constructor_nimbusclient_new( @@ -780,8 +780,7 @@ public convenience init(appCtx: AppContext, recordedContext: RecordedContext?, c FfiConverterString.lower(dbpath), FfiConverterCallbackInterfaceMetricsHandler_lower(metricsHandler), FfiConverterOptionCallbackInterfaceGeckoPrefHandler.lower(geckoPrefHandler), - FfiConverterOptionTypeRemoteSettingsService.lower(remoteSettingsService), - FfiConverterOptionString.lower(collectionName),$0 + FfiConverterOptionTypeNimbusServerSettings.lower(remoteSettingsInfo),$0 ) } self.init(unsafeFromHandle: handle) @@ -2532,6 +2531,60 @@ public func FfiConverterTypeMalformedFeatureConfigExtraDef_lower(_ value: Malfor } +public struct NimbusServerSettings { + public var rsService: RemoteSettingsService + public var collectionName: String + + // Default memberwise initializers are never public by default, so we + // declare one manually. + public init(rsService: RemoteSettingsService, collectionName: String) { + self.rsService = rsService + self.collectionName = collectionName + } + + + + +} + +#if compiler(>=6) +extension NimbusServerSettings: Sendable {} +#endif + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public struct FfiConverterTypeNimbusServerSettings: FfiConverterRustBuffer { + public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NimbusServerSettings { + return + try NimbusServerSettings( + rsService: FfiConverterTypeRemoteSettingsService.read(from: &buf), + collectionName: FfiConverterString.read(from: &buf) + ) + } + + public static func write(_ value: NimbusServerSettings, into buf: inout [UInt8]) { + FfiConverterTypeRemoteSettingsService.write(value.rsService, into: &buf) + FfiConverterString.write(value.collectionName, into: &buf) + } +} + + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeNimbusServerSettings_lift(_ buf: RustBuffer) throws -> NimbusServerSettings { + return try FfiConverterTypeNimbusServerSettings.lift(buf) +} + +#if swift(>=5.8) +@_documentation(visibility: private) +#endif +public func FfiConverterTypeNimbusServerSettings_lower(_ value: NimbusServerSettings) -> RustBuffer { + return FfiConverterTypeNimbusServerSettings.lower(value) +} + + public struct OriginalGeckoPref: Equatable, Hashable { public var pref: String public var branch: PrefBranch @@ -3684,8 +3737,8 @@ fileprivate struct FfiConverterOptionTypeRecordedContext: FfiConverterRustBuffer #if swift(>=5.8) @_documentation(visibility: private) #endif -fileprivate struct FfiConverterOptionTypeRemoteSettingsService: FfiConverterRustBuffer { - typealias SwiftType = RemoteSettingsService? +fileprivate struct FfiConverterOptionTypeNimbusServerSettings: FfiConverterRustBuffer { + typealias SwiftType = NimbusServerSettings? public static func write(_ value: SwiftType, into buf: inout [UInt8]) { guard let value = value else { @@ -3693,13 +3746,13 @@ fileprivate struct FfiConverterOptionTypeRemoteSettingsService: FfiConverterRust return } writeInt(&buf, Int8(1)) - FfiConverterTypeRemoteSettingsService.write(value, into: &buf) + FfiConverterTypeNimbusServerSettings.write(value, into: &buf) } public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType { switch try readInt(&buf) as Int8 { case 0: return nil - case 1: return try FfiConverterTypeRemoteSettingsService.read(from: &buf) + case 1: return try FfiConverterTypeNimbusServerSettings.read(from: &buf) default: throw UniffiInternalError.unexpectedOptionalTag } } @@ -4403,7 +4456,7 @@ private let initializationResult: InitializationResult = { if (uniffi_nimbus_checksum_method_recordedcontext_to_json() != 52035) { return InitializationResult.apiChecksumMismatch } - if (uniffi_nimbus_checksum_constructor_nimbusclient_new() != 28763) { + if (uniffi_nimbus_checksum_constructor_nimbusclient_new() != 32755) { return InitializationResult.apiChecksumMismatch } if (uniffi_nimbus_checksum_method_geckoprefhandler_get_prefs_with_state() != 27063) { diff --git a/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusApi.swift b/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusApi.swift index 340d4ebe3355f..821d89c0d6c49 100644 --- a/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusApi.swift +++ b/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusApi.swift @@ -239,18 +239,6 @@ public extension Notification.Name { static let nimbusExperimentsApplied = Notification.Name("nimbusExperimentsApplied") } -/// This struct is used during in the `create` method to point `Nimbus` at the given `RemoteSettings` server. -/// -public struct NimbusServerSettings { - public init(remoteSettingsService: RemoteSettingsService, collection: String = remoteSettingsCollection) { - self.remoteSettingsService = remoteSettingsService - self.collection = collection - } - - public let remoteSettingsService: RemoteSettingsService - public let collection: String -} - public let remoteSettingsCollection = "nimbus-mobile-experiments" public let remoteSettingsPreviewCollection = "nimbus-preview" diff --git a/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusBuilder.swift b/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusBuilder.swift index d8fd4b4f8c128..dad437a33455f 100644 --- a/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusBuilder.swift +++ b/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusBuilder.swift @@ -193,9 +193,9 @@ public class NimbusBuilder { ) -> NimbusInterface { let serverSettings: NimbusServerSettings? if usePreviewCollection { - serverSettings = NimbusServerSettings(remoteSettingsService: remoteSettingsService, collection: remoteSettingsPreviewCollection) + serverSettings = NimbusServerSettings(rsService: remoteSettingsService, collectionName: remoteSettingsPreviewCollection) } else { - serverSettings = NimbusServerSettings(remoteSettingsService: remoteSettingsService, collection: remoteSettingsCollection) + serverSettings = NimbusServerSettings(rsService: remoteSettingsService, collectionName: remoteSettingsCollection) } do { @@ -260,7 +260,7 @@ public class NimbusBuilder { _ appInfo: NimbusAppSettings, serverSettings: NimbusServerSettings? ) throws -> NimbusInterface { - try Nimbus.create(serverSettings, + try Nimbus.create(server: serverSettings, appSettings: appInfo, coenrollingFeatureIds: getCoenrollingFeatureIds(), dbPath: dbFilePath, diff --git a/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusCreate.swift b/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusCreate.swift index 2b8bb5d974ca7..9f8188c792d5a 100644 --- a/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusCreate.swift +++ b/MozillaRustComponents/Sources/MozillaRustComponentsWrapper/Nimbus/NimbusCreate.swift @@ -77,7 +77,7 @@ public extension Nimbus { /// - Throws `NimbusError` if anything goes wrong with the Rust FFI or in the `NimbusClient` constructor. /// static func create( - _ server: NimbusServerSettings?, + server: NimbusServerSettings?, appSettings: NimbusAppSettings, coenrollingFeatureIds: [String] = [], dbPath: String, @@ -99,8 +99,7 @@ public extension Nimbus { dbpath: dbPath, metricsHandler: GleanMetricsHandler(), geckoPrefHandler: nil, - remoteSettingsService: server?.remoteSettingsService, - collectionName: server?.collection + remoteSettingsInfo: server, ) return Nimbus( diff --git a/focus-ios/Blockzilla/Nimbus/NimbusExtensions.swift b/focus-ios/Blockzilla/Nimbus/NimbusExtensions.swift index 8c6714afa754a..649520b4ffc9d 100644 --- a/focus-ios/Blockzilla/Nimbus/NimbusExtensions.swift +++ b/focus-ios/Blockzilla/Nimbus/NimbusExtensions.swift @@ -17,10 +17,7 @@ extension NimbusServerSettings { /// from the `Info.plist`, or if it failes to parse as a valid URL, then `nil` is returned. /// - Returns: NimbusServerSettings static func createFromInfoDictionary(useStagingServer: Bool, usePreviewCollection: Bool) -> NimbusServerSettings? { - guard let serverURL = getNimbusEndpoint(useStagingServer: useStagingServer) else { - return nil - } - return NimbusServerSettings(url: serverURL, collection: usePreviewCollection ? "nimbus-preview" : remoteSettingsCollection) + return nil } static func getNimbusEndpoint(useStagingServer: Bool) -> URL? {