Revision control

Copy as Markdown

// This file was autogenerated by some hot garbage in the `uniffi` crate.
// Trust me, you don't want to mess with it!
// swiftlint:disable all
import Foundation
// Depending on the consumer's build setup, the low-level FFI code
// might be in a separate module, or it might be compiled inline into
// this module. This is a bit of light hackery to work with both.
#if canImport(MozillaRustComponents)
import MozillaRustComponents
#endif
fileprivate extension RustBuffer {
// Allocate a new buffer, copying the contents of a `UInt8` array.
init(bytes: [UInt8]) {
let rbuf = bytes.withUnsafeBufferPointer { ptr in
RustBuffer.from(ptr)
}
self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data)
}
static func empty() -> RustBuffer {
RustBuffer(capacity: 0, len:0, data: nil)
}
static func from(_ ptr: UnsafeBufferPointer<UInt8>) -> RustBuffer {
try! rustCall { ffi_nimbus_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
}
// Frees the buffer in place.
// The buffer must not be used after this is called.
func deallocate() {
try! rustCall { ffi_nimbus_rustbuffer_free(self, $0) }
}
}
fileprivate extension ForeignBytes {
init(bufferPointer: UnsafeBufferPointer<UInt8>) {
self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress)
}
init(rawBufferPointer: UnsafeRawBufferPointer) {
self.init(
len: Int32(rawBufferPointer.count),
data: rawBufferPointer.baseAddress?.assumingMemoryBound(to: UInt8.self)
)
}
}
// Converter for `&[u8]` / `[ByRef] bytes` arguments.
//
// Conforms to `FfiConverter` so the compiler enforces the full converter
// method set. Only the scope-bound `lower(_:_body:)` overload is sound —
// zero-copy byte buffers only flow foreign -> Rust, and only in argument
// position. The four protocol-witness methods (`lift`, `lower`, `read`,
// `write`) `fatalError` at runtime if anyone reaches them.
//
// The scope-bound `lower` takes a closure because the `ForeignBytes`
// pointer is only guaranteed valid for the duration of
// `Data.withUnsafeBytes`. Callers must run the full FFI call inside
// the closure body.
fileprivate enum FfiConverterByRefBytes: FfiConverter {
typealias SwiftType = Data
typealias FfiType = ForeignBytes
static func lower<R>(_ value: Data, _ body: (ForeignBytes) throws -> R) rethrows -> R {
return try value.withUnsafeBytes { rawBuf in
try body(ForeignBytes(rawBufferPointer: rawBuf))
}
}
static func lower(_ value: Data) -> ForeignBytes {
fatalError("ByRef bytes cannot use the plain lower: returning ForeignBytes escapes the Data.withUnsafeBytes scope. Use the scope-bound lower(_:_body:) overload instead.")
}
static func lift(_ value: ForeignBytes) throws -> Data {
fatalError("ByRef bytes cannot be lifted: zero-copy &[u8] only flows foreign->Rust")
}
static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data {
fatalError("ByRef bytes cannot be read from a buffer: zero-copy &[u8] is only supported in argument position, not nested in records/options/etc.")
}
static func write(_ value: Data, into buf: inout [UInt8]) {
fatalError("ByRef bytes cannot be written to a buffer: zero-copy &[u8] is only supported in argument position, not nested in records/options/etc.")
}
}
// For every type used in the interface, we provide helper methods for conveniently
// lifting and lowering that type from C-compatible data, and for reading and writing
// values of that type in a buffer.
// Helper classes/extensions that don't change.
// Someday, this will be in a library of its own.
fileprivate extension Data {
init(rustBuffer: RustBuffer) {
self.init(
bytesNoCopy: rustBuffer.data!,
count: Int(rustBuffer.len),
deallocator: .none
)
}
}
// Define reader functionality. Normally this would be defined in a class or
// struct, but we use standalone functions instead in order to make external
// types work.
//
// With external types, one swift source file needs to be able to call the read
// method on another source file's FfiConverter, but then what visibility
// should Reader have?
// - If Reader is fileprivate, then this means the read() must also
// be fileprivate, which doesn't work with external types.
// - If Reader is internal/public, we'll get compile errors since both source
// files will try define the same type.
//
// Instead, the read() method and these helper functions input a tuple of data
fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) {
(data: data, offset: 0)
}
// Reads an integer at the current offset, in big-endian order, and advances
// the offset on success. Throws if reading the integer would move the
// offset past the end of the buffer.
fileprivate func readInt<T: FixedWidthInteger>(_ reader: inout (data: Data, offset: Data.Index)) throws -> T {
let range = reader.offset..<reader.offset + MemoryLayout<T>.size
guard reader.data.count >= range.upperBound else {
throw UniffiInternalError.bufferOverflow
}
if T.self == UInt8.self {
let value = reader.data[reader.offset]
reader.offset += 1
return value as! T
}
var value: T = 0
let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)})
reader.offset = range.upperBound
return value.bigEndian
}
// Reads an arbitrary number of bytes, to be used to read
// raw bytes, this is useful when lifting strings
fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array<UInt8> {
let range = reader.offset..<(reader.offset+count)
guard reader.data.count >= range.upperBound else {
throw UniffiInternalError.bufferOverflow
}
var value = [UInt8](repeating: 0, count: count)
value.withUnsafeMutableBufferPointer({ buffer in
reader.data.copyBytes(to: buffer, from: range)
})
reader.offset = range.upperBound
return value
}
// Reads a float at the current offset.
fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float {
return Float(bitPattern: try readInt(&reader))
}
// Reads a float at the current offset.
fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double {
return Double(bitPattern: try readInt(&reader))
}
// Indicates if the offset has reached the end of the buffer.
fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool {
return reader.offset < reader.data.count
}
// Define writer functionality. Normally this would be defined in a class or
// struct, but we use standalone functions instead in order to make external
// types work. See the above discussion on Readers for details.
fileprivate func createWriter() -> [UInt8] {
return []
}
fileprivate func writeBytes<S>(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 {
writer.append(contentsOf: byteArr)
}
// Writes an integer in big-endian order.
//
// Warning: make sure what you are trying to write
// is in the correct type!
fileprivate func writeInt<T: FixedWidthInteger>(_ writer: inout [UInt8], _ value: T) {
var value = value.bigEndian
withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) }
}
fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) {
writeInt(&writer, value.bitPattern)
}
fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) {
writeInt(&writer, value.bitPattern)
}
// Protocol for types that transfer other types across the FFI. This is
// analogous to the Rust trait of the same name.
fileprivate protocol FfiConverter {
associatedtype FfiType
associatedtype SwiftType
static func lift(_ value: FfiType) throws -> SwiftType
static func lower(_ value: SwiftType) -> FfiType
static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType
static func write(_ value: SwiftType, into buf: inout [UInt8])
}
// Types conforming to `Primitive` pass themselves directly over the FFI.
fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { }
extension FfiConverterPrimitive {
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public static func lift(_ value: FfiType) throws -> SwiftType {
return value
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public static func lower(_ value: SwiftType) -> FfiType {
return value
}
}
// Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`.
// Used for complex types where it's hard to write a custom lift/lower.
fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {}
extension FfiConverterRustBuffer {
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public static func lift(_ buf: RustBuffer) throws -> SwiftType {
var reader = createReader(data: Data(rustBuffer: buf))
let value = try read(from: &reader)
if hasRemaining(reader) {
throw UniffiInternalError.incompleteData
}
buf.deallocate()
return value
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public static func lower(_ value: SwiftType) -> RustBuffer {
var writer = createWriter()
write(value, into: &writer)
return RustBuffer(bytes: writer)
}
}
// An error type for FFI errors. These errors occur at the UniFFI level, not
// the library level.
fileprivate enum UniffiInternalError: LocalizedError {
case bufferOverflow
case incompleteData
case unexpectedOptionalTag
case unexpectedEnumCase
case unexpectedNullPointer
case unexpectedRustCallStatusCode
case unexpectedRustCallError
case unexpectedStaleHandle
case rustPanic(_ message: String)
public var errorDescription: String? {
switch self {
case .bufferOverflow: return "Reading the requested value would read past the end of the buffer"
case .incompleteData: return "The buffer still has data after lifting its containing value"
case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1"
case .unexpectedEnumCase: return "Raw enum value doesn't match any cases"
case .unexpectedNullPointer: return "Raw pointer value was null"
case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code"
case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified"
case .unexpectedStaleHandle: return "The object in the handle map has been dropped already"
case let .rustPanic(message): return message
}
}
}
fileprivate extension NSLock {
func withLock<T>(f: () throws -> T) rethrows -> T {
self.lock()
defer { self.unlock() }
return try f()
}
}
fileprivate let CALL_SUCCESS: Int8 = 0
fileprivate let CALL_ERROR: Int8 = 1
fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2
fileprivate let CALL_CANCELLED: Int8 = 3
fileprivate extension RustCallStatus {
init() {
self.init(
code: CALL_SUCCESS,
errorBuf: RustBuffer.init(
capacity: 0,
len: 0,
data: nil
)
)
}
}
private func rustCall<T>(_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
let neverThrow: ((RustBuffer) throws -> Never)? = nil
return try makeRustCall(callback, errorHandler: neverThrow)
}
private func rustCallWithError<T, E: Swift.Error>(
_ errorHandler: @escaping (RustBuffer) throws -> E,
_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
try makeRustCall(callback, errorHandler: errorHandler)
}
private func makeRustCall<T, E: Swift.Error>(
_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T,
errorHandler: ((RustBuffer) throws -> E)?
) throws -> T {
uniffiEnsureNimbusInitialized()
var callStatus = RustCallStatus.init()
let returnedVal = callback(&callStatus)
try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler)
return returnedVal
}
private func uniffiCheckCallStatus<E: Swift.Error>(
callStatus: RustCallStatus,
errorHandler: ((RustBuffer) throws -> E)?
) throws {
switch callStatus.code {
case CALL_SUCCESS:
return
case CALL_ERROR:
if let errorHandler = errorHandler {
throw try errorHandler(callStatus.errorBuf)
} else {
callStatus.errorBuf.deallocate()
throw UniffiInternalError.unexpectedRustCallError
}
case CALL_UNEXPECTED_ERROR:
// When the rust code sees a panic, it tries to construct a RustBuffer
// with the message. But if that code panics, then it just sends back
// an empty buffer.
if callStatus.errorBuf.len > 0 {
throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf))
} else {
callStatus.errorBuf.deallocate()
throw UniffiInternalError.rustPanic("Rust panic")
}
case CALL_CANCELLED:
fatalError("Cancellation not supported yet")
default:
throw UniffiInternalError.unexpectedRustCallStatusCode
}
}
private func uniffiTraitInterfaceCall<T>(
callStatus: UnsafeMutablePointer<RustCallStatus>,
makeCall: () throws -> T,
writeReturn: (T) -> ()
) {
do {
try writeReturn(makeCall())
} catch let error {
callStatus.pointee.code = CALL_UNEXPECTED_ERROR
callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
}
}
private func uniffiTraitInterfaceCallWithError<T, E>(
callStatus: UnsafeMutablePointer<RustCallStatus>,
makeCall: () throws -> T,
writeReturn: (T) -> (),
lowerError: (E) -> RustBuffer
) {
do {
try writeReturn(makeCall())
} catch let error as E {
callStatus.pointee.code = CALL_ERROR
callStatus.pointee.errorBuf = lowerError(error)
} catch {
callStatus.pointee.code = CALL_UNEXPECTED_ERROR
callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
}
}
// Initial value and increment amount for handles.
// These ensure that SWIFT handles always have the lowest bit set
fileprivate let UNIFFI_HANDLEMAP_INITIAL: UInt64 = 1
fileprivate let UNIFFI_HANDLEMAP_DELTA: UInt64 = 2
fileprivate final class UniffiHandleMap<T>: @unchecked Sendable {
// All mutation happens with this lock held, which is why we implement @unchecked Sendable.
private let lock = NSLock()
private var map: [UInt64: T] = [:]
private var currentHandle: UInt64 = UNIFFI_HANDLEMAP_INITIAL
func insert(obj: T) -> UInt64 {
lock.withLock {
return doInsert(obj)
}
}
// Low-level insert function, this assumes `lock` is held.
private func doInsert(_ obj: T) -> UInt64 {
let handle = currentHandle
currentHandle += UNIFFI_HANDLEMAP_DELTA
map[handle] = obj
return handle
}
func get(handle: UInt64) throws -> T {
try lock.withLock {
guard let obj = map[handle] else {
throw UniffiInternalError.unexpectedStaleHandle
}
return obj
}
}
func clone(handle: UInt64) throws -> UInt64 {
try lock.withLock {
guard let obj = map[handle] else {
throw UniffiInternalError.unexpectedStaleHandle
}
return doInsert(obj)
}
}
@discardableResult
func remove(handle: UInt64) throws -> T {
try lock.withLock {
guard let obj = map.removeValue(forKey: handle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return obj
}
}
var count: Int {
get {
map.count
}
}
}
// Public interface members begin here.
// Magic number for the Rust proxy to call using the same mechanism as every other method,
// to free the callback once it's dropped by Rust.
private let IDX_CALLBACK_FREE: Int32 = 0
// Callback return codes
private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0
private let UNIFFI_CALLBACK_ERROR: Int32 = 1
private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterUInt16: FfiConverterPrimitive {
typealias FfiType = UInt16
typealias SwiftType = UInt16
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt16 {
return try lift(readInt(&buf))
}
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
writeInt(&buf, lower(value))
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterInt32: FfiConverterPrimitive {
typealias FfiType = Int32
typealias SwiftType = Int32
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Int32 {
return try lift(readInt(&buf))
}
public static func write(_ value: Int32, into buf: inout [UInt8]) {
writeInt(&buf, lower(value))
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterInt64: FfiConverterPrimitive {
typealias FfiType = Int64
typealias SwiftType = Int64
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Int64 {
return try lift(readInt(&buf))
}
public static func write(_ value: Int64, into buf: inout [UInt8]) {
writeInt(&buf, lower(value))
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterDouble: FfiConverterPrimitive {
typealias FfiType = Double
typealias SwiftType = Double
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Double {
return try lift(readDouble(&buf))
}
public static func write(_ value: Double, into buf: inout [UInt8]) {
writeDouble(&buf, lower(value))
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterBool : FfiConverter {
typealias FfiType = Int8
typealias SwiftType = Bool
public static func lift(_ value: Int8) throws -> Bool {
return value != 0
}
public static func lower(_ value: Bool) -> Int8 {
return value ? 1 : 0
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool {
return try lift(readInt(&buf))
}
public static func write(_ value: Bool, into buf: inout [UInt8]) {
writeInt(&buf, lower(value))
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterString: FfiConverter {
typealias SwiftType = String
typealias FfiType = RustBuffer
public static func lift(_ value: RustBuffer) throws -> String {
defer {
value.deallocate()
}
if value.data == nil {
return String()
}
let bytes = UnsafeBufferPointer<UInt8>(start: value.data!, count: Int(value.len))
// Use Swift's native UTF-8 decoder; `String(bytes:encoding:.utf8)` goes
// through Foundation's NSString and silently strips a leading U+FEFF BOM.
// Invalid UTF-8 substitutes U+FFFD instead of trapping (unreachable
// given Rust's `String` invariant).
return String(decoding: bytes, as: UTF8.self)
}
public static func lower(_ value: String) -> RustBuffer {
return value.utf8CString.withUnsafeBufferPointer { ptr in
// The swift string gives us int8_t, we want uint8_t.
ptr.withMemoryRebound(to: UInt8.self) { ptr in
// The swift string gives us a trailing null byte, we don't want it.
let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1))
return RustBuffer.from(buf)
}
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String {
let len: Int32 = try readInt(&buf)
// See `lift` above for why we avoid Foundation's NSString-backed decoder here.
return String(decoding: try readBytes(&buf, count: Int(len)), as: UTF8.self)
}
public static func write(_ value: String, into buf: inout [UInt8]) {
let len = Int32(value.utf8.count)
writeInt(&buf, len)
writeBytes(&buf, value.utf8)
}
}
public protocol GeckoPrefHandler: AnyObject, Sendable {
func getPrefsWithState() -> [String: [String: GeckoPrefState]]
func setGeckoPrefsOriginalValues(originalGeckoPrefs: [OriginalGeckoPref])
func setGeckoPrefsState(newPrefsState: [GeckoPrefState])
}
open class GeckoPrefHandlerImpl: GeckoPrefHandler, @unchecked Sendable {
fileprivate let handle: UInt64
/// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct NoHandle {
public init() {}
}
// TODO: We'd like this to be `private` but for Swifty reasons,
// we can't implement `FfiConverter` without making this `required` and we can't
// make it `required` without making it `public`.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
required public init(unsafeFromHandle handle: UInt64) {
self.handle = handle
}
// This constructor can be used to instantiate a fake object.
// - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
//
// - Warning:
// Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public init(noHandle: NoHandle) {
self.handle = 0
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func uniffiCloneHandle() -> UInt64 {
return try! rustCall { uniffi_nimbus_fn_clone_geckoprefhandler(self.handle, $0) }
}
// No primary constructor declared for this class.
deinit {
if handle == 0 {
// Mock objects have handle=0 don't try to free them
return
}
try! rustCall { uniffi_nimbus_fn_free_geckoprefhandler(handle, $0) }
}
open func getPrefsWithState() -> [String: [String: GeckoPrefState]] {
return try! FfiConverterDictionaryStringDictionaryStringTypeGeckoPrefState.lift(try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_geckoprefhandler_get_prefs_with_state(
self.uniffiCloneHandle(),uniffiCallStatus
)
})
}
open func setGeckoPrefsOriginalValues(originalGeckoPrefs: [OriginalGeckoPref]) {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_geckoprefhandler_set_gecko_prefs_original_values(
self.uniffiCloneHandle(),
FfiConverterSequenceTypeOriginalGeckoPref.lower(originalGeckoPrefs),uniffiCallStatus
)
}
}
open func setGeckoPrefsState(newPrefsState: [GeckoPrefState]) {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_geckoprefhandler_set_gecko_prefs_state(
self.uniffiCloneHandle(),
FfiConverterSequenceTypeGeckoPrefState.lower(newPrefsState),uniffiCallStatus
)
}
}
}
// Put the implementation in a struct so we don't pollute the top-level namespace
fileprivate struct UniffiCallbackInterfaceGeckoPrefHandler {
// Create the VTable using a series of closures.
// Swift automatically converts these into C callback functions.
//
// Store the vtable directly.
static let vtable: UniffiVTableCallbackInterfaceGeckoPrefHandler = UniffiVTableCallbackInterfaceGeckoPrefHandler(
uniffiFree: { (uniffiHandle: UInt64) -> () in
do {
try FfiConverterTypeGeckoPrefHandler.handleMap.remove(handle: uniffiHandle)
} catch {
print("Uniffi callback interface GeckoPrefHandler: handle missing in uniffiFree")
}
},
uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in
do {
return try FfiConverterTypeGeckoPrefHandler.handleMap.clone(handle: uniffiHandle)
} catch {
fatalError("Uniffi callback interface GeckoPrefHandler: handle missing in uniffiClone")
}
},
getPrefsWithState: { (
uniffiHandle: UInt64,
uniffiOutReturn: UnsafeMutablePointer<RustBuffer>,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> [String: [String: GeckoPrefState]] in
guard let uniffiObj = try? FfiConverterTypeGeckoPrefHandler.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.getPrefsWithState(
)
}
let writeReturn = { uniffiOutReturn.pointee = FfiConverterDictionaryStringDictionaryStringTypeGeckoPrefState.lower($0) }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
},
setGeckoPrefsOriginalValues: { (
uniffiHandle: UInt64,
originalGeckoPrefs: RustBuffer,
uniffiOutReturn: UnsafeMutableRawPointer,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> () in
guard let uniffiObj = try? FfiConverterTypeGeckoPrefHandler.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.setGeckoPrefsOriginalValues(
originalGeckoPrefs: try FfiConverterSequenceTypeOriginalGeckoPref.lift(originalGeckoPrefs)
)
}
let writeReturn = { () }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
},
setGeckoPrefsState: { (
uniffiHandle: UInt64,
newPrefsState: RustBuffer,
uniffiOutReturn: UnsafeMutableRawPointer,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> () in
guard let uniffiObj = try? FfiConverterTypeGeckoPrefHandler.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.setGeckoPrefsState(
newPrefsState: try FfiConverterSequenceTypeGeckoPrefState.lift(newPrefsState)
)
}
let writeReturn = { () }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
}
)
// Rust stores this pointer for future callback invocations, so it must live
// for the process lifetime (not just for the init function call).
//
// `nonisolated(unsafe)` is needed under Swift 6 strict concurrency.
// This is safe because the pointee is initialized once during static init
// and never mutated by either side of the FFI. Its fields are C function pointers.
nonisolated(unsafe) static let vtablePtr: UnsafePointer<UniffiVTableCallbackInterfaceGeckoPrefHandler> = {
let ptr = UnsafeMutablePointer<UniffiVTableCallbackInterfaceGeckoPrefHandler>.allocate(capacity: 1)
ptr.initialize(to: vtable)
return UnsafePointer(ptr)
}()
}
private func uniffiCallbackInitGeckoPrefHandler() {
uniffi_nimbus_fn_init_callback_vtable_geckoprefhandler(UniffiCallbackInterfaceGeckoPrefHandler.vtablePtr)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeGeckoPrefHandler: FfiConverter {
fileprivate static let handleMap = UniffiHandleMap<GeckoPrefHandler>()
typealias FfiType = UInt64
typealias SwiftType = GeckoPrefHandler
public static func lift(_ handle: UInt64) throws -> GeckoPrefHandler {
if ((handle & 1) == 0) {
// Rust-generated handle, construct a new class that uses the handle to implement the
// interface
return GeckoPrefHandlerImpl(unsafeFromHandle: handle)
} else {
// Swift-generated handle, get the object from the handle map
return try handleMap.remove(handle: handle)
}
}
public static func lower(_ value: GeckoPrefHandler) -> UInt64 {
if let rustImpl = value as? GeckoPrefHandlerImpl {
// Rust-implemented object. Clone the handle and return it
return rustImpl.uniffiCloneHandle()
} else {
// Swift object, generate a new vtable handle and return that.
return handleMap.insert(obj: value)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GeckoPrefHandler {
let handle: UInt64 = try readInt(&buf)
return try lift(handle)
}
public static func write(_ value: GeckoPrefHandler, into buf: inout [UInt8]) {
writeInt(&buf, lower(value))
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeGeckoPrefHandler_lift(_ handle: UInt64) throws -> GeckoPrefHandler {
return try FfiConverterTypeGeckoPrefHandler.lift(handle)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeGeckoPrefHandler_lower(_ value: GeckoPrefHandler) -> UInt64 {
return FfiConverterTypeGeckoPrefHandler.lower(value)
}
public protocol MetricsHandler: AnyObject, Sendable {
func recordDatabaseLoad(event: DatabaseLoadExtraDef)
func recordDatabaseMigration(event: DatabaseMigrationExtraDef)
func recordEnrollmentStatuses(enrollmentStatusExtras: [EnrollmentStatusExtraDef])
/**
* Feature activation is the pre-cursor to feature exposure: it is defined as the first time
* the feature configuration is asked for.
*/
func recordFeatureActivation(event: FeatureExposureExtraDef)
func recordFeatureExposure(event: FeatureExposureExtraDef)
func recordMalformedFeatureConfig(event: MalformedFeatureConfigExtraDef)
func recordRolloutsOptOut()
func recordStudiesOptOut()
func submitTargetingContext()
}
open class MetricsHandlerImpl: MetricsHandler, @unchecked Sendable {
fileprivate let handle: UInt64
/// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct NoHandle {
public init() {}
}
// TODO: We'd like this to be `private` but for Swifty reasons,
// we can't implement `FfiConverter` without making this `required` and we can't
// make it `required` without making it `public`.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
required public init(unsafeFromHandle handle: UInt64) {
self.handle = handle
}
// This constructor can be used to instantiate a fake object.
// - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
//
// - Warning:
// Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public init(noHandle: NoHandle) {
self.handle = 0
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func uniffiCloneHandle() -> UInt64 {
return try! rustCall { uniffi_nimbus_fn_clone_metricshandler(self.handle, $0) }
}
// No primary constructor declared for this class.
deinit {
if handle == 0 {
// Mock objects have handle=0 don't try to free them
return
}
try! rustCall { uniffi_nimbus_fn_free_metricshandler(handle, $0) }
}
open func recordDatabaseLoad(event: DatabaseLoadExtraDef) {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_metricshandler_record_database_load(
self.uniffiCloneHandle(),
FfiConverterTypeDatabaseLoadExtraDef_lower(event),uniffiCallStatus
)
}
}
open func recordDatabaseMigration(event: DatabaseMigrationExtraDef) {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_metricshandler_record_database_migration(
self.uniffiCloneHandle(),
FfiConverterTypeDatabaseMigrationExtraDef_lower(event),uniffiCallStatus
)
}
}
open func recordEnrollmentStatuses(enrollmentStatusExtras: [EnrollmentStatusExtraDef]) {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_metricshandler_record_enrollment_statuses(
self.uniffiCloneHandle(),
FfiConverterSequenceTypeEnrollmentStatusExtraDef.lower(enrollmentStatusExtras),uniffiCallStatus
)
}
}
/**
* Feature activation is the pre-cursor to feature exposure: it is defined as the first time
* the feature configuration is asked for.
*/
open func recordFeatureActivation(event: FeatureExposureExtraDef) {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_metricshandler_record_feature_activation(
self.uniffiCloneHandle(),
FfiConverterTypeFeatureExposureExtraDef_lower(event),uniffiCallStatus
)
}
}
open func recordFeatureExposure(event: FeatureExposureExtraDef) {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_metricshandler_record_feature_exposure(
self.uniffiCloneHandle(),
FfiConverterTypeFeatureExposureExtraDef_lower(event),uniffiCallStatus
)
}
}
open func recordMalformedFeatureConfig(event: MalformedFeatureConfigExtraDef) {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_metricshandler_record_malformed_feature_config(
self.uniffiCloneHandle(),
FfiConverterTypeMalformedFeatureConfigExtraDef_lower(event),uniffiCallStatus
)
}
}
open func recordRolloutsOptOut() {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_metricshandler_record_rollouts_opt_out(
self.uniffiCloneHandle(),uniffiCallStatus
)
}
}
open func recordStudiesOptOut() {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_metricshandler_record_studies_opt_out(
self.uniffiCloneHandle(),uniffiCallStatus
)
}
}
open func submitTargetingContext() {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_metricshandler_submit_targeting_context(
self.uniffiCloneHandle(),uniffiCallStatus
)
}
}
}
// Put the implementation in a struct so we don't pollute the top-level namespace
fileprivate struct UniffiCallbackInterfaceMetricsHandler {
// Create the VTable using a series of closures.
// Swift automatically converts these into C callback functions.
//
// Store the vtable directly.
static let vtable: UniffiVTableCallbackInterfaceMetricsHandler = UniffiVTableCallbackInterfaceMetricsHandler(
uniffiFree: { (uniffiHandle: UInt64) -> () in
do {
try FfiConverterTypeMetricsHandler.handleMap.remove(handle: uniffiHandle)
} catch {
print("Uniffi callback interface MetricsHandler: handle missing in uniffiFree")
}
},
uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in
do {
return try FfiConverterTypeMetricsHandler.handleMap.clone(handle: uniffiHandle)
} catch {
fatalError("Uniffi callback interface MetricsHandler: handle missing in uniffiClone")
}
},
recordDatabaseLoad: { (
uniffiHandle: UInt64,
event: RustBuffer,
uniffiOutReturn: UnsafeMutableRawPointer,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> () in
guard let uniffiObj = try? FfiConverterTypeMetricsHandler.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.recordDatabaseLoad(
event: try FfiConverterTypeDatabaseLoadExtraDef_lift(event)
)
}
let writeReturn = { () }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
},
recordDatabaseMigration: { (
uniffiHandle: UInt64,
event: RustBuffer,
uniffiOutReturn: UnsafeMutableRawPointer,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> () in
guard let uniffiObj = try? FfiConverterTypeMetricsHandler.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.recordDatabaseMigration(
event: try FfiConverterTypeDatabaseMigrationExtraDef_lift(event)
)
}
let writeReturn = { () }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
},
recordEnrollmentStatuses: { (
uniffiHandle: UInt64,
enrollmentStatusExtras: RustBuffer,
uniffiOutReturn: UnsafeMutableRawPointer,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> () in
guard let uniffiObj = try? FfiConverterTypeMetricsHandler.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.recordEnrollmentStatuses(
enrollmentStatusExtras: try FfiConverterSequenceTypeEnrollmentStatusExtraDef.lift(enrollmentStatusExtras)
)
}
let writeReturn = { () }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
},
recordFeatureActivation: { (
uniffiHandle: UInt64,
event: RustBuffer,
uniffiOutReturn: UnsafeMutableRawPointer,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> () in
guard let uniffiObj = try? FfiConverterTypeMetricsHandler.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.recordFeatureActivation(
event: try FfiConverterTypeFeatureExposureExtraDef_lift(event)
)
}
let writeReturn = { () }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
},
recordFeatureExposure: { (
uniffiHandle: UInt64,
event: RustBuffer,
uniffiOutReturn: UnsafeMutableRawPointer,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> () in
guard let uniffiObj = try? FfiConverterTypeMetricsHandler.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.recordFeatureExposure(
event: try FfiConverterTypeFeatureExposureExtraDef_lift(event)
)
}
let writeReturn = { () }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
},
recordMalformedFeatureConfig: { (
uniffiHandle: UInt64,
event: RustBuffer,
uniffiOutReturn: UnsafeMutableRawPointer,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> () in
guard let uniffiObj = try? FfiConverterTypeMetricsHandler.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.recordMalformedFeatureConfig(
event: try FfiConverterTypeMalformedFeatureConfigExtraDef_lift(event)
)
}
let writeReturn = { () }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
},
recordRolloutsOptOut: { (
uniffiHandle: UInt64,
uniffiOutReturn: UnsafeMutableRawPointer,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> () in
guard let uniffiObj = try? FfiConverterTypeMetricsHandler.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.recordRolloutsOptOut(
)
}
let writeReturn = { () }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
},
recordStudiesOptOut: { (
uniffiHandle: UInt64,
uniffiOutReturn: UnsafeMutableRawPointer,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> () in
guard let uniffiObj = try? FfiConverterTypeMetricsHandler.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.recordStudiesOptOut(
)
}
let writeReturn = { () }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
},
submitTargetingContext: { (
uniffiHandle: UInt64,
uniffiOutReturn: UnsafeMutableRawPointer,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> () in
guard let uniffiObj = try? FfiConverterTypeMetricsHandler.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.submitTargetingContext(
)
}
let writeReturn = { () }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
}
)
// Rust stores this pointer for future callback invocations, so it must live
// for the process lifetime (not just for the init function call).
//
// `nonisolated(unsafe)` is needed under Swift 6 strict concurrency.
// This is safe because the pointee is initialized once during static init
// and never mutated by either side of the FFI. Its fields are C function pointers.
nonisolated(unsafe) static let vtablePtr: UnsafePointer<UniffiVTableCallbackInterfaceMetricsHandler> = {
let ptr = UnsafeMutablePointer<UniffiVTableCallbackInterfaceMetricsHandler>.allocate(capacity: 1)
ptr.initialize(to: vtable)
return UnsafePointer(ptr)
}()
}
private func uniffiCallbackInitMetricsHandler() {
uniffi_nimbus_fn_init_callback_vtable_metricshandler(UniffiCallbackInterfaceMetricsHandler.vtablePtr)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeMetricsHandler: FfiConverter {
fileprivate static let handleMap = UniffiHandleMap<MetricsHandler>()
typealias FfiType = UInt64
typealias SwiftType = MetricsHandler
public static func lift(_ handle: UInt64) throws -> MetricsHandler {
if ((handle & 1) == 0) {
// Rust-generated handle, construct a new class that uses the handle to implement the
// interface
return MetricsHandlerImpl(unsafeFromHandle: handle)
} else {
// Swift-generated handle, get the object from the handle map
return try handleMap.remove(handle: handle)
}
}
public static func lower(_ value: MetricsHandler) -> UInt64 {
if let rustImpl = value as? MetricsHandlerImpl {
// Rust-implemented object. Clone the handle and return it
return rustImpl.uniffiCloneHandle()
} else {
// Swift object, generate a new vtable handle and return that.
return handleMap.insert(obj: value)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MetricsHandler {
let handle: UInt64 = try readInt(&buf)
return try lift(handle)
}
public static func write(_ value: MetricsHandler, into buf: inout [UInt8]) {
writeInt(&buf, lower(value))
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeMetricsHandler_lift(_ handle: UInt64) throws -> MetricsHandler {
return try FfiConverterTypeMetricsHandler.lift(handle)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeMetricsHandler_lower(_ value: MetricsHandler) -> UInt64 {
return FfiConverterTypeMetricsHandler.lower(value)
}
public protocol NimbusClientProtocol: AnyObject, Sendable {
/**
* Advances what the event store thinks is now.
* This, and `record_past_event` are useful for testing.
* `by_seconds` must be positive.
*/
func advanceEventTime(bySeconds: Int64) throws
/**
* Apply the updated experiments from the last fetch.
* After calling this, the list of active experiments might change
* (there might be new experiments, or old experiments might have expired).
*/
func applyPendingExperiments() throws -> [EnrollmentChangeEvent]
func clearEvents() throws
/**
* This provides a unified String interpolation library which exposes the application context.
* It's first use is in the messaging helper, to add extra parameters to URLs.
*/
func createStringHelper(additionalContext: JsonObject?) throws -> NimbusStringHelper
/**
* This provides low level access to the targeting machinery for other uses by the application (e.g. messages)
* Additional parameters can be added via the optional JSON object. This allows for many JEXL expressions
* to be run across the same context.
*/
func createTargetingHelper(additionalContext: JsonObject?) throws -> NimbusTargetingHelper
func dumpStateToLog() throws
func enrollInFirefoxLab(slug: String) throws -> FirefoxLabsEnrollResult
/**
* Fetches the list of experiments from the server. This does not affect the list
* of active experiments or experiment enrolment.
* Fetched experiments are not applied until `apply_pending_updates()` is called.
*/
func fetchExperiments() throws
/**
* Returns a list of experiments this user is enrolled in.
*/
func getActiveExperiments() throws -> [EnrolledExperiment]
/**
* Returns a list of experiments for this `app_name`, as specified in the `AppContext`.
* It is not intended to be used to be used for user facing applications.
*/
func getAvailableExperiments() throws -> [AvailableExperiment]
func getAvailableFirefoxLabs() throws -> [FirefoxLabsMetadata]
/**
* Returns the branch allocated for a given slug or id.
*/
func getExperimentBranch(id: String) throws -> String?
/**
* Returns a list of experiment branches for a given experiment ID.
*/
func getExperimentBranches(experimentSlug: String) throws -> [ExperimentBranch]
/**
* Getter and setter for user's participation in experiments only.
* Possible values are:
* * `true`: the user will enroll in experiments as usual.
* * `false`: the user will not enroll in new experiments, and opt out of all existing ones.
*/
func getExperimentParticipation() throws -> Bool
func getFeatureConfigVariables(featureId: String) throws -> String?
func getPreviousGeckoPrefStates(experimentSlug: String) throws -> [PreviousGeckoPrefState]?
/**
* Getter and setter for user's participation in rollouts.
* Possible values are:
* * `true`: the user will enroll in rollouts as usual.
* * `false`: the user will not enroll in new rollouts, and opt out of all existing ones.
*/
func getRolloutParticipation() throws -> Bool
/**
* Initializes the database and caches enough information so that the
* non-blocking API functions (eg, `get_experiment_branch()`) can
* return accurate results rather than throwing a "not initialized" error.
* It's not strictly necessary to call this function - any function that
* wants to use the database will implicitly initialize too - this exists
* so that the consuming application can have confidence the non-blocking
* functions will return data instead of returning an error, and will do
* the minimum amount of work to achieve that.
*/
func initialize() throws
func isFetchEnabled() throws -> Bool
/**
* Opt in to a specific branch on a specific experiment. Useful for
* developers to test their app's interaction with the experiment.
*/
func optInWithBranch(experimentSlug: String, branch: String) throws -> [EnrollmentChangeEvent]
/**
* Opt out of a specific experiment.
*/
func optOut(experimentSlug: String) throws -> [EnrollmentChangeEvent]
/**
* Records an event for the purposes of behavioral targeting.
* This function is used to record and persist data used for the behavioral
* targeting such as "core-active" user targeting.
*/
func recordEvent(eventId: String, count: Int64) throws
/**
* Records a Glean event that this feature has been exposed.
* If the feature is not involved in an experiment, then the event is suppressed.
* If the feature is only involved in a rollout, then the event is suppressed.
* If the feature is involved in an experiment, then record the experiment slug
* and branch.
* If the feature is involved in an experiment and a rollout, then record only the
* experiment slug and branch.
* If the slug is specified, then use this as the experiment, and use it to look up
* the branch. This is useful for coenrolling features.
*/
func recordFeatureExposure(featureId: String, slug: String?)
/**
* Records a Glean event that this feature configuration is malformed.
* Accepts a part_id to give the experiment owner or feature implementer
* clues where to look.
* The Glean event will always fire, but the content of that event will
* vary depending on whether then feature is part of an experiment or rollout
* or not.
*/
func recordMalformedFeatureConfig(featureId: String, partId: String)
/**
* Records an event as if it were in the past.
* This, and `advance_event_time` are useful for testing.
* `seconds_ago` must be positive.
*/
func recordPastEvent(eventId: String, secondsAgo: Int64, count: Int64) throws
func registerPreviousGeckoPrefStates(geckoPrefStates: [GeckoPrefState]) throws
/**
* These are test-only functions and should never be exposed to production
* users, as they mess with the "statistical requirements" of the SDK.
* Reset the enrollments and experiments in the database to an empty state.
*/
func resetEnrollments() throws
/**
* Reset internal state in response to application-level telemetry reset.
*
* Consumers should call this method when the user resets the telemetry state of the
* consuming application, such as by opting out of submitting telemetry. It resets the
* internal state of the Nimbus client to create a clean break between data collected
* before and after the reset, including:
*
* * clearing any unique identifiers used internally, so they will reset to
* new random values on next use.
* * accepting new randomization units, based on application-level ids that
* may have also changed.
* * disqualifying this client out of any active experiments, to avoid submitting
* misleading incomplete data.
*/
func resetTelemetryIdentifiers() throws -> [EnrollmentChangeEvent]
func setExperimentParticipation(optIn: Bool) throws -> [EnrollmentChangeEvent]
/**
* A convenience method for apps to set the experiments from a local source
* for either testing, or before the first fetch has finished.
*
* Experiments set with this method are not applied until `apply_pending_updates()` is called.
*/
func setExperimentsLocally(experimentsJson: String) throws
/**
* Toggles the enablement of the fetch. If `false`, then calling `fetch_experiments`
* returns immediately, having not done any fetching from remote settings.
* This is only useful for QA, and should not be used in production: use
* `set_experiment_participation` or `set_rollout_participation` instead.
*/
func setFetchEnabled(flag: Bool) throws
func setRolloutParticipation(optIn: Bool) throws -> [EnrollmentChangeEvent]
func unenrollForGeckoPref(prefState: GeckoPrefState, prefUnenrollReason: PrefUnenrollReason) throws -> [EnrollmentChangeEvent]
func unenrollFromAllFirefoxLabs() throws -> [EnrollmentChangeEvent]
func unenrollFromFirefoxLab(slug: String) throws -> FirefoxLabsUnenrollResult
}
open class NimbusClient: NimbusClientProtocol, @unchecked Sendable {
fileprivate let handle: UInt64
/// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct NoHandle {
public init() {}
}
// TODO: We'd like this to be `private` but for Swifty reasons,
// we can't implement `FfiConverter` without making this `required` and we can't
// make it `required` without making it `public`.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
required public init(unsafeFromHandle handle: UInt64) {
self.handle = handle
}
// This constructor can be used to instantiate a fake object.
// - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
//
// - Warning:
// Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public init(noHandle: NoHandle) {
self.handle = 0
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
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?, remoteSettingsInfo: NimbusServerSettings?)throws {
let handle =
try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_constructor_nimbusclient_new(
FfiConverterTypeAppContext_lower(appCtx),
FfiConverterOptionTypeRecordedContext.lower(recordedContext),
FfiConverterSequenceString.lower(coenrollingFeatureIds),
FfiConverterString.lower(dbpath),
FfiConverterTypeMetricsHandler_lower(metricsHandler),
FfiConverterOptionTypeGeckoPrefHandler.lower(geckoPrefHandler),
FfiConverterOptionTypeNimbusServerSettings.lower(remoteSettingsInfo),uniffiCallStatus
)
}
self.init(unsafeFromHandle: handle)
}
deinit {
if handle == 0 {
// Mock objects have handle=0 don't try to free them
return
}
try! rustCall { uniffi_nimbus_fn_free_nimbusclient(handle, $0) }
}
/**
* Advances what the event store thinks is now.
* This, and `record_past_event` are useful for testing.
* `by_seconds` must be positive.
*/
open func advanceEventTime(bySeconds: Int64)throws {try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_advance_event_time(
self.uniffiCloneHandle(),
FfiConverterInt64.lower(bySeconds),uniffiCallStatus
)
}
}
/**
* Apply the updated experiments from the last fetch.
* After calling this, the list of active experiments might change
* (there might be new experiments, or old experiments might have expired).
*/
open func applyPendingExperiments()throws -> [EnrollmentChangeEvent] {
return try FfiConverterSequenceTypeEnrollmentChangeEvent.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_apply_pending_experiments(
self.uniffiCloneHandle(),uniffiCallStatus
)
})
}
open func clearEvents()throws {try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_clear_events(
self.uniffiCloneHandle(),uniffiCallStatus
)
}
}
/**
* This provides a unified String interpolation library which exposes the application context.
* It's first use is in the messaging helper, to add extra parameters to URLs.
*/
open func createStringHelper(additionalContext: JsonObject? = nil)throws -> NimbusStringHelper {
return try FfiConverterTypeNimbusStringHelper_lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_create_string_helper(
self.uniffiCloneHandle(),
FfiConverterOptionTypeJsonObject.lower(additionalContext),uniffiCallStatus
)
})
}
/**
* This provides low level access to the targeting machinery for other uses by the application (e.g. messages)
* Additional parameters can be added via the optional JSON object. This allows for many JEXL expressions
* to be run across the same context.
*/
open func createTargetingHelper(additionalContext: JsonObject? = nil)throws -> NimbusTargetingHelper {
return try FfiConverterTypeNimbusTargetingHelper_lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_create_targeting_helper(
self.uniffiCloneHandle(),
FfiConverterOptionTypeJsonObject.lower(additionalContext),uniffiCallStatus
)
})
}
open func dumpStateToLog()throws {try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_dump_state_to_log(
self.uniffiCloneHandle(),uniffiCallStatus
)
}
}
open func enrollInFirefoxLab(slug: String)throws -> FirefoxLabsEnrollResult {
return try FfiConverterTypeFirefoxLabsEnrollResult_lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_enroll_in_firefox_lab(
self.uniffiCloneHandle(),
FfiConverterString.lower(slug),uniffiCallStatus
)
})
}
/**
* Fetches the list of experiments from the server. This does not affect the list
* of active experiments or experiment enrolment.
* Fetched experiments are not applied until `apply_pending_updates()` is called.
*/
open func fetchExperiments()throws {try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_fetch_experiments(
self.uniffiCloneHandle(),uniffiCallStatus
)
}
}
/**
* Returns a list of experiments this user is enrolled in.
*/
open func getActiveExperiments()throws -> [EnrolledExperiment] {
return try FfiConverterSequenceTypeEnrolledExperiment.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_get_active_experiments(
self.uniffiCloneHandle(),uniffiCallStatus
)
})
}
/**
* Returns a list of experiments for this `app_name`, as specified in the `AppContext`.
* It is not intended to be used to be used for user facing applications.
*/
open func getAvailableExperiments()throws -> [AvailableExperiment] {
return try FfiConverterSequenceTypeAvailableExperiment.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_get_available_experiments(
self.uniffiCloneHandle(),uniffiCallStatus
)
})
}
open func getAvailableFirefoxLabs()throws -> [FirefoxLabsMetadata] {
return try FfiConverterSequenceTypeFirefoxLabsMetadata.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_get_available_firefox_labs(
self.uniffiCloneHandle(),uniffiCallStatus
)
})
}
/**
* Returns the branch allocated for a given slug or id.
*/
open func getExperimentBranch(id: String)throws -> String? {
return try FfiConverterOptionString.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_get_experiment_branch(
self.uniffiCloneHandle(),
FfiConverterString.lower(id),uniffiCallStatus
)
})
}
/**
* Returns a list of experiment branches for a given experiment ID.
*/
open func getExperimentBranches(experimentSlug: String)throws -> [ExperimentBranch] {
return try FfiConverterSequenceTypeExperimentBranch.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_get_experiment_branches(
self.uniffiCloneHandle(),
FfiConverterString.lower(experimentSlug),uniffiCallStatus
)
})
}
/**
* Getter and setter for user's participation in experiments only.
* Possible values are:
* * `true`: the user will enroll in experiments as usual.
* * `false`: the user will not enroll in new experiments, and opt out of all existing ones.
*/
open func getExperimentParticipation()throws -> Bool {
return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_get_experiment_participation(
self.uniffiCloneHandle(),uniffiCallStatus
)
})
}
open func getFeatureConfigVariables(featureId: String)throws -> String? {
return try FfiConverterOptionString.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_get_feature_config_variables(
self.uniffiCloneHandle(),
FfiConverterString.lower(featureId),uniffiCallStatus
)
})
}
open func getPreviousGeckoPrefStates(experimentSlug: String)throws -> [PreviousGeckoPrefState]? {
return try FfiConverterOptionSequenceTypePreviousGeckoPrefState.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_get_previous_gecko_pref_states(
self.uniffiCloneHandle(),
FfiConverterString.lower(experimentSlug),uniffiCallStatus
)
})
}
/**
* Getter and setter for user's participation in rollouts.
* Possible values are:
* * `true`: the user will enroll in rollouts as usual.
* * `false`: the user will not enroll in new rollouts, and opt out of all existing ones.
*/
open func getRolloutParticipation()throws -> Bool {
return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_get_rollout_participation(
self.uniffiCloneHandle(),uniffiCallStatus
)
})
}
/**
* Initializes the database and caches enough information so that the
* non-blocking API functions (eg, `get_experiment_branch()`) can
* return accurate results rather than throwing a "not initialized" error.
* It's not strictly necessary to call this function - any function that
* wants to use the database will implicitly initialize too - this exists
* so that the consuming application can have confidence the non-blocking
* functions will return data instead of returning an error, and will do
* the minimum amount of work to achieve that.
*/
open func initialize()throws {try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_initialize(
self.uniffiCloneHandle(),uniffiCallStatus
)
}
}
open func isFetchEnabled()throws -> Bool {
return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_is_fetch_enabled(
self.uniffiCloneHandle(),uniffiCallStatus
)
})
}
/**
* Opt in to a specific branch on a specific experiment. Useful for
* developers to test their app's interaction with the experiment.
*/
open func optInWithBranch(experimentSlug: String, branch: String)throws -> [EnrollmentChangeEvent] {
return try FfiConverterSequenceTypeEnrollmentChangeEvent.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_opt_in_with_branch(
self.uniffiCloneHandle(),
FfiConverterString.lower(experimentSlug),
FfiConverterString.lower(branch),uniffiCallStatus
)
})
}
/**
* Opt out of a specific experiment.
*/
open func optOut(experimentSlug: String)throws -> [EnrollmentChangeEvent] {
return try FfiConverterSequenceTypeEnrollmentChangeEvent.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_opt_out(
self.uniffiCloneHandle(),
FfiConverterString.lower(experimentSlug),uniffiCallStatus
)
})
}
/**
* Records an event for the purposes of behavioral targeting.
* This function is used to record and persist data used for the behavioral
* targeting such as "core-active" user targeting.
*/
open func recordEvent(eventId: String, count: Int64 = Int64(1))throws {try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_record_event(
self.uniffiCloneHandle(),
FfiConverterString.lower(eventId),
FfiConverterInt64.lower(count),uniffiCallStatus
)
}
}
/**
* Records a Glean event that this feature has been exposed.
* If the feature is not involved in an experiment, then the event is suppressed.
* If the feature is only involved in a rollout, then the event is suppressed.
* If the feature is involved in an experiment, then record the experiment slug
* and branch.
* If the feature is involved in an experiment and a rollout, then record only the
* experiment slug and branch.
* If the slug is specified, then use this as the experiment, and use it to look up
* the branch. This is useful for coenrolling features.
*/
open func recordFeatureExposure(featureId: String, slug: String?) {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_record_feature_exposure(
self.uniffiCloneHandle(),
FfiConverterString.lower(featureId),
FfiConverterOptionString.lower(slug),uniffiCallStatus
)
}
}
/**
* Records a Glean event that this feature configuration is malformed.
* Accepts a part_id to give the experiment owner or feature implementer
* clues where to look.
* The Glean event will always fire, but the content of that event will
* vary depending on whether then feature is part of an experiment or rollout
* or not.
*/
open func recordMalformedFeatureConfig(featureId: String, partId: String) {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_record_malformed_feature_config(
self.uniffiCloneHandle(),
FfiConverterString.lower(featureId),
FfiConverterString.lower(partId),uniffiCallStatus
)
}
}
/**
* Records an event as if it were in the past.
* This, and `advance_event_time` are useful for testing.
* `seconds_ago` must be positive.
*/
open func recordPastEvent(eventId: String, secondsAgo: Int64, count: Int64 = Int64(1))throws {try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_record_past_event(
self.uniffiCloneHandle(),
FfiConverterString.lower(eventId),
FfiConverterInt64.lower(secondsAgo),
FfiConverterInt64.lower(count),uniffiCallStatus
)
}
}
open func registerPreviousGeckoPrefStates(geckoPrefStates: [GeckoPrefState])throws {try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_register_previous_gecko_pref_states(
self.uniffiCloneHandle(),
FfiConverterSequenceTypeGeckoPrefState.lower(geckoPrefStates),uniffiCallStatus
)
}
}
/**
* These are test-only functions and should never be exposed to production
* users, as they mess with the "statistical requirements" of the SDK.
* Reset the enrollments and experiments in the database to an empty state.
*/
open func resetEnrollments()throws {try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_reset_enrollments(
self.uniffiCloneHandle(),uniffiCallStatus
)
}
}
/**
* Reset internal state in response to application-level telemetry reset.
*
* Consumers should call this method when the user resets the telemetry state of the
* consuming application, such as by opting out of submitting telemetry. It resets the
* internal state of the Nimbus client to create a clean break between data collected
* before and after the reset, including:
*
* * clearing any unique identifiers used internally, so they will reset to
* new random values on next use.
* * accepting new randomization units, based on application-level ids that
* may have also changed.
* * disqualifying this client out of any active experiments, to avoid submitting
* misleading incomplete data.
*/
open func resetTelemetryIdentifiers()throws -> [EnrollmentChangeEvent] {
return try FfiConverterSequenceTypeEnrollmentChangeEvent.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_reset_telemetry_identifiers(
self.uniffiCloneHandle(),uniffiCallStatus
)
})
}
open func setExperimentParticipation(optIn: Bool)throws -> [EnrollmentChangeEvent] {
return try FfiConverterSequenceTypeEnrollmentChangeEvent.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_set_experiment_participation(
self.uniffiCloneHandle(),
FfiConverterBool.lower(optIn),uniffiCallStatus
)
})
}
/**
* A convenience method for apps to set the experiments from a local source
* for either testing, or before the first fetch has finished.
*
* Experiments set with this method are not applied until `apply_pending_updates()` is called.
*/
open func setExperimentsLocally(experimentsJson: String)throws {try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_set_experiments_locally(
self.uniffiCloneHandle(),
FfiConverterString.lower(experimentsJson),uniffiCallStatus
)
}
}
/**
* Toggles the enablement of the fetch. If `false`, then calling `fetch_experiments`
* returns immediately, having not done any fetching from remote settings.
* This is only useful for QA, and should not be used in production: use
* `set_experiment_participation` or `set_rollout_participation` instead.
*/
open func setFetchEnabled(flag: Bool)throws {try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_set_fetch_enabled(
self.uniffiCloneHandle(),
FfiConverterBool.lower(flag),uniffiCallStatus
)
}
}
open func setRolloutParticipation(optIn: Bool)throws -> [EnrollmentChangeEvent] {
return try FfiConverterSequenceTypeEnrollmentChangeEvent.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_set_rollout_participation(
self.uniffiCloneHandle(),
FfiConverterBool.lower(optIn),uniffiCallStatus
)
})
}
open func unenrollForGeckoPref(prefState: GeckoPrefState, prefUnenrollReason: PrefUnenrollReason)throws -> [EnrollmentChangeEvent] {
return try FfiConverterSequenceTypeEnrollmentChangeEvent.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_unenroll_for_gecko_pref(
self.uniffiCloneHandle(),
FfiConverterTypeGeckoPrefState_lower(prefState),
FfiConverterTypePrefUnenrollReason_lower(prefUnenrollReason),uniffiCallStatus
)
})
}
open func unenrollFromAllFirefoxLabs()throws -> [EnrollmentChangeEvent] {
return try FfiConverterSequenceTypeEnrollmentChangeEvent.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_unenroll_from_all_firefox_labs(
self.uniffiCloneHandle(),uniffiCallStatus
)
})
}
open func unenrollFromFirefoxLab(slug: String)throws -> FirefoxLabsUnenrollResult {
return try FfiConverterTypeFirefoxLabsUnenrollResult_lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusclient_unenroll_from_firefox_lab(
self.uniffiCloneHandle(),
FfiConverterString.lower(slug),uniffiCallStatus
)
})
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeNimbusClient: FfiConverter {
typealias FfiType = UInt64
typealias SwiftType = NimbusClient
public static func lift(_ handle: UInt64) throws -> NimbusClient {
return NimbusClient(unsafeFromHandle: handle)
}
public static func lower(_ value: NimbusClient) -> UInt64 {
return value.uniffiCloneHandle()
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NimbusClient {
let handle: UInt64 = try readInt(&buf)
return try lift(handle)
}
public static func write(_ value: NimbusClient, into buf: inout [UInt8]) {
writeInt(&buf, lower(value))
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeNimbusClient_lift(_ handle: UInt64) throws -> NimbusClient {
return try FfiConverterTypeNimbusClient.lift(handle)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeNimbusClient_lower(_ value: NimbusClient) -> UInt64 {
return FfiConverterTypeNimbusClient.lower(value)
}
public protocol NimbusStringHelperProtocol: AnyObject, Sendable {
/**
* Generates an optional UUID to be passed into the `string_format` method.
* If the return is not null, then it should be recorded with Glean as a UuidMetricType.
*/
func getUuid(template: String) -> String?
/**
* Take the given template and find patterns that match the regular expression `{\w+}`.
* Any matches are used as keys into the application context, the `additional_context` or the special case `uuid`.
*/
func stringFormat(template: String, uuid: String?) -> String
}
open class NimbusStringHelper: NimbusStringHelperProtocol, @unchecked Sendable {
fileprivate let handle: UInt64
/// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct NoHandle {
public init() {}
}
// TODO: We'd like this to be `private` but for Swifty reasons,
// we can't implement `FfiConverter` without making this `required` and we can't
// make it `required` without making it `public`.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
required public init(unsafeFromHandle handle: UInt64) {
self.handle = handle
}
// This constructor can be used to instantiate a fake object.
// - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
//
// - Warning:
// Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public init(noHandle: NoHandle) {
self.handle = 0
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func uniffiCloneHandle() -> UInt64 {
return try! rustCall { uniffi_nimbus_fn_clone_nimbusstringhelper(self.handle, $0) }
}
// No primary constructor declared for this class.
deinit {
if handle == 0 {
// Mock objects have handle=0 don't try to free them
return
}
try! rustCall { uniffi_nimbus_fn_free_nimbusstringhelper(handle, $0) }
}
/**
* Generates an optional UUID to be passed into the `string_format` method.
* If the return is not null, then it should be recorded with Glean as a UuidMetricType.
*/
open func getUuid(template: String) -> String? {
return try! FfiConverterOptionString.lift(try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusstringhelper_get_uuid(
self.uniffiCloneHandle(),
FfiConverterString.lower(template),uniffiCallStatus
)
})
}
/**
* Take the given template and find patterns that match the regular expression `{\w+}`.
* Any matches are used as keys into the application context, the `additional_context` or the special case `uuid`.
*/
open func stringFormat(template: String, uuid: String? = nil) -> String {
return try! FfiConverterString.lift(try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbusstringhelper_string_format(
self.uniffiCloneHandle(),
FfiConverterString.lower(template),
FfiConverterOptionString.lower(uuid),uniffiCallStatus
)
})
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeNimbusStringHelper: FfiConverter {
typealias FfiType = UInt64
typealias SwiftType = NimbusStringHelper
public static func lift(_ handle: UInt64) throws -> NimbusStringHelper {
return NimbusStringHelper(unsafeFromHandle: handle)
}
public static func lower(_ value: NimbusStringHelper) -> UInt64 {
return value.uniffiCloneHandle()
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NimbusStringHelper {
let handle: UInt64 = try readInt(&buf)
return try lift(handle)
}
public static func write(_ value: NimbusStringHelper, into buf: inout [UInt8]) {
writeInt(&buf, lower(value))
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeNimbusStringHelper_lift(_ handle: UInt64) throws -> NimbusStringHelper {
return try FfiConverterTypeNimbusStringHelper.lift(handle)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeNimbusStringHelper_lower(_ value: NimbusStringHelper) -> UInt64 {
return FfiConverterTypeNimbusStringHelper.lower(value)
}
public protocol NimbusTargetingHelperProtocol: AnyObject, Sendable {
/**
* Execute the given jexl expression and evaluate against the existing targeting parameters and context passed to
* the helper at construction.
*/
func evalJexl(expression: String) throws -> Bool
/**
* Evaluate a JEXL expression and return debug results as JSON.
* For CLI testing and debugging.
*/
func evalJexlDebug(expression: String) throws -> String
}
open class NimbusTargetingHelper: NimbusTargetingHelperProtocol, @unchecked Sendable {
fileprivate let handle: UInt64
/// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct NoHandle {
public init() {}
}
// TODO: We'd like this to be `private` but for Swifty reasons,
// we can't implement `FfiConverter` without making this `required` and we can't
// make it `required` without making it `public`.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
required public init(unsafeFromHandle handle: UInt64) {
self.handle = handle
}
// This constructor can be used to instantiate a fake object.
// - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
//
// - Warning:
// Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public init(noHandle: NoHandle) {
self.handle = 0
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func uniffiCloneHandle() -> UInt64 {
return try! rustCall { uniffi_nimbus_fn_clone_nimbustargetinghelper(self.handle, $0) }
}
// No primary constructor declared for this class.
deinit {
if handle == 0 {
// Mock objects have handle=0 don't try to free them
return
}
try! rustCall { uniffi_nimbus_fn_free_nimbustargetinghelper(handle, $0) }
}
/**
* Execute the given jexl expression and evaluate against the existing targeting parameters and context passed to
* the helper at construction.
*/
open func evalJexl(expression: String)throws -> Bool {
return try FfiConverterBool.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbustargetinghelper_eval_jexl(
self.uniffiCloneHandle(),
FfiConverterString.lower(expression),uniffiCallStatus
)
})
}
/**
* Evaluate a JEXL expression and return debug results as JSON.
* For CLI testing and debugging.
*/
open func evalJexlDebug(expression: String)throws -> String {
return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_method_nimbustargetinghelper_eval_jexl_debug(
self.uniffiCloneHandle(),
FfiConverterString.lower(expression),uniffiCallStatus
)
})
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeNimbusTargetingHelper: FfiConverter {
typealias FfiType = UInt64
typealias SwiftType = NimbusTargetingHelper
public static func lift(_ handle: UInt64) throws -> NimbusTargetingHelper {
return NimbusTargetingHelper(unsafeFromHandle: handle)
}
public static func lower(_ value: NimbusTargetingHelper) -> UInt64 {
return value.uniffiCloneHandle()
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NimbusTargetingHelper {
let handle: UInt64 = try readInt(&buf)
return try lift(handle)
}
public static func write(_ value: NimbusTargetingHelper, into buf: inout [UInt8]) {
writeInt(&buf, lower(value))
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeNimbusTargetingHelper_lift(_ handle: UInt64) throws -> NimbusTargetingHelper {
return try FfiConverterTypeNimbusTargetingHelper.lift(handle)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeNimbusTargetingHelper_lower(_ value: NimbusTargetingHelper) -> UInt64 {
return FfiConverterTypeNimbusTargetingHelper.lower(value)
}
public protocol RecordedContext: AnyObject, Sendable {
func getEventQueries() -> [String: String]
func record()
func setEventQueryValues(eventQueryValues: [String: Double])
func toJson() -> JsonObject
}
open class RecordedContextImpl: RecordedContext, @unchecked Sendable {
fileprivate let handle: UInt64
/// Used to instantiate a [FFIObject] without an actual handle, for fakes in tests, mostly.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct NoHandle {
public init() {}
}
// TODO: We'd like this to be `private` but for Swifty reasons,
// we can't implement `FfiConverter` without making this `required` and we can't
// make it `required` without making it `public`.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
required public init(unsafeFromHandle handle: UInt64) {
self.handle = handle
}
// This constructor can be used to instantiate a fake object.
// - Parameter noHandle: Placeholder value so we can have a constructor separate from the default empty one that may be implemented for classes extending [FFIObject].
//
// - Warning:
// Any object instantiated with this constructor cannot be passed to an actual Rust-backed object. Since there isn't a backing handle the FFI lower functions will crash.
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public init(noHandle: NoHandle) {
self.handle = 0
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func uniffiCloneHandle() -> UInt64 {
return try! rustCall { uniffi_nimbus_fn_clone_recordedcontext(self.handle, $0) }
}
// No primary constructor declared for this class.
deinit {
if handle == 0 {
// Mock objects have handle=0 don't try to free them
return
}
try! rustCall { uniffi_nimbus_fn_free_recordedcontext(handle, $0) }
}
open func getEventQueries() -> [String: String] {
return try! FfiConverterDictionaryStringString.lift(try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_recordedcontext_get_event_queries(
self.uniffiCloneHandle(),uniffiCallStatus
)
})
}
open func record() {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_recordedcontext_record(
self.uniffiCloneHandle(),uniffiCallStatus
)
}
}
open func setEventQueryValues(eventQueryValues: [String: Double]) {try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_recordedcontext_set_event_query_values(
self.uniffiCloneHandle(),
FfiConverterDictionaryStringDouble.lower(eventQueryValues),uniffiCallStatus
)
}
}
open func toJson() -> JsonObject {
return try! FfiConverterTypeJsonObject_lift(try! rustCall() {
uniffiCallStatus in
uniffi_nimbus_fn_method_recordedcontext_to_json(
self.uniffiCloneHandle(),uniffiCallStatus
)
})
}
}
// Put the implementation in a struct so we don't pollute the top-level namespace
fileprivate struct UniffiCallbackInterfaceRecordedContext {
// Create the VTable using a series of closures.
// Swift automatically converts these into C callback functions.
//
// Store the vtable directly.
static let vtable: UniffiVTableCallbackInterfaceRecordedContext = UniffiVTableCallbackInterfaceRecordedContext(
uniffiFree: { (uniffiHandle: UInt64) -> () in
do {
try FfiConverterTypeRecordedContext.handleMap.remove(handle: uniffiHandle)
} catch {
print("Uniffi callback interface RecordedContext: handle missing in uniffiFree")
}
},
uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in
do {
return try FfiConverterTypeRecordedContext.handleMap.clone(handle: uniffiHandle)
} catch {
fatalError("Uniffi callback interface RecordedContext: handle missing in uniffiClone")
}
},
getEventQueries: { (
uniffiHandle: UInt64,
uniffiOutReturn: UnsafeMutablePointer<RustBuffer>,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> [String: String] in
guard let uniffiObj = try? FfiConverterTypeRecordedContext.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.getEventQueries(
)
}
let writeReturn = { uniffiOutReturn.pointee = FfiConverterDictionaryStringString.lower($0) }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
},
record: { (
uniffiHandle: UInt64,
uniffiOutReturn: UnsafeMutableRawPointer,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> () in
guard let uniffiObj = try? FfiConverterTypeRecordedContext.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.record(
)
}
let writeReturn = { () }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
},
setEventQueryValues: { (
uniffiHandle: UInt64,
eventQueryValues: RustBuffer,
uniffiOutReturn: UnsafeMutableRawPointer,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> () in
guard let uniffiObj = try? FfiConverterTypeRecordedContext.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.setEventQueryValues(
eventQueryValues: try FfiConverterDictionaryStringDouble.lift(eventQueryValues)
)
}
let writeReturn = { () }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
},
toJson: { (
uniffiHandle: UInt64,
uniffiOutReturn: UnsafeMutablePointer<RustBuffer>,
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
) in
let makeCall = {
() throws -> JsonObject in
guard let uniffiObj = try? FfiConverterTypeRecordedContext.handleMap.get(handle: uniffiHandle) else {
throw UniffiInternalError.unexpectedStaleHandle
}
return uniffiObj.toJson(
)
}
let writeReturn = { uniffiOutReturn.pointee = FfiConverterTypeJsonObject_lower($0) }
uniffiTraitInterfaceCall(
callStatus: uniffiCallStatus,
makeCall: makeCall,
writeReturn: writeReturn
)
}
)
// Rust stores this pointer for future callback invocations, so it must live
// for the process lifetime (not just for the init function call).
//
// `nonisolated(unsafe)` is needed under Swift 6 strict concurrency.
// This is safe because the pointee is initialized once during static init
// and never mutated by either side of the FFI. Its fields are C function pointers.
nonisolated(unsafe) static let vtablePtr: UnsafePointer<UniffiVTableCallbackInterfaceRecordedContext> = {
let ptr = UnsafeMutablePointer<UniffiVTableCallbackInterfaceRecordedContext>.allocate(capacity: 1)
ptr.initialize(to: vtable)
return UnsafePointer(ptr)
}()
}
private func uniffiCallbackInitRecordedContext() {
uniffi_nimbus_fn_init_callback_vtable_recordedcontext(UniffiCallbackInterfaceRecordedContext.vtablePtr)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeRecordedContext: FfiConverter {
fileprivate static let handleMap = UniffiHandleMap<RecordedContext>()
typealias FfiType = UInt64
typealias SwiftType = RecordedContext
public static func lift(_ handle: UInt64) throws -> RecordedContext {
if ((handle & 1) == 0) {
// Rust-generated handle, construct a new class that uses the handle to implement the
// interface
return RecordedContextImpl(unsafeFromHandle: handle)
} else {
// Swift-generated handle, get the object from the handle map
return try handleMap.remove(handle: handle)
}
}
public static func lower(_ value: RecordedContext) -> UInt64 {
if let rustImpl = value as? RecordedContextImpl {
// Rust-implemented object. Clone the handle and return it
return rustImpl.uniffiCloneHandle()
} else {
// Swift object, generate a new vtable handle and return that.
return handleMap.insert(obj: value)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RecordedContext {
let handle: UInt64 = try readInt(&buf)
return try lift(handle)
}
public static func write(_ value: RecordedContext, into buf: inout [UInt8]) {
writeInt(&buf, lower(value))
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRecordedContext_lift(_ handle: UInt64) throws -> RecordedContext {
return try FfiConverterTypeRecordedContext.lift(handle)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRecordedContext_lower(_ value: RecordedContext) -> UInt64 {
return FfiConverterTypeRecordedContext.lower(value)
}
public struct AppContext: Equatable, Hashable {
public var appName: String
public var appId: String
public var channel: String
public var appVersion: String?
public var appBuild: String?
public var architecture: String?
public var deviceManufacturer: String?
public var deviceModel: String?
public var locale: String?
public var os: String?
public var osVersion: String?
public var androidSdkVersion: String?
public var debugTag: String?
public var installationDate: Int64?
public var customTargetingAttributes: JsonObject?
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(appName: String, appId: String, channel: String, appVersion: String?, appBuild: String?, architecture: String?, deviceManufacturer: String?, deviceModel: String?, locale: String?, os: String?, osVersion: String?, androidSdkVersion: String?, debugTag: String?, installationDate: Int64?, customTargetingAttributes: JsonObject?) {
self.appName = appName
self.appId = appId
self.channel = channel
self.appVersion = appVersion
self.appBuild = appBuild
self.architecture = architecture
self.deviceManufacturer = deviceManufacturer
self.deviceModel = deviceModel
self.locale = locale
self.os = os
self.osVersion = osVersion
self.androidSdkVersion = androidSdkVersion
self.debugTag = debugTag
self.installationDate = installationDate
self.customTargetingAttributes = customTargetingAttributes
}
}
#if compiler(>=6)
extension AppContext: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeAppContext: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppContext {
return
try AppContext(
appName: FfiConverterString.read(from: &buf),
appId: FfiConverterString.read(from: &buf),
channel: FfiConverterString.read(from: &buf),
appVersion: FfiConverterOptionString.read(from: &buf),
appBuild: FfiConverterOptionString.read(from: &buf),
architecture: FfiConverterOptionString.read(from: &buf),
deviceManufacturer: FfiConverterOptionString.read(from: &buf),
deviceModel: FfiConverterOptionString.read(from: &buf),
locale: FfiConverterOptionString.read(from: &buf),
os: FfiConverterOptionString.read(from: &buf),
osVersion: FfiConverterOptionString.read(from: &buf),
androidSdkVersion: FfiConverterOptionString.read(from: &buf),
debugTag: FfiConverterOptionString.read(from: &buf),
installationDate: FfiConverterOptionInt64.read(from: &buf),
customTargetingAttributes: FfiConverterOptionTypeJsonObject.read(from: &buf)
)
}
public static func write(_ value: AppContext, into buf: inout [UInt8]) {
FfiConverterString.write(value.appName, into: &buf)
FfiConverterString.write(value.appId, into: &buf)
FfiConverterString.write(value.channel, into: &buf)
FfiConverterOptionString.write(value.appVersion, into: &buf)
FfiConverterOptionString.write(value.appBuild, into: &buf)
FfiConverterOptionString.write(value.architecture, into: &buf)
FfiConverterOptionString.write(value.deviceManufacturer, into: &buf)
FfiConverterOptionString.write(value.deviceModel, into: &buf)
FfiConverterOptionString.write(value.locale, into: &buf)
FfiConverterOptionString.write(value.os, into: &buf)
FfiConverterOptionString.write(value.osVersion, into: &buf)
FfiConverterOptionString.write(value.androidSdkVersion, into: &buf)
FfiConverterOptionString.write(value.debugTag, into: &buf)
FfiConverterOptionInt64.write(value.installationDate, into: &buf)
FfiConverterOptionTypeJsonObject.write(value.customTargetingAttributes, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeAppContext_lift(_ buf: RustBuffer) throws -> AppContext {
return try FfiConverterTypeAppContext.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeAppContext_lower(_ value: AppContext) -> RustBuffer {
return FfiConverterTypeAppContext.lower(value)
}
public struct AvailableExperiment: Equatable, Hashable {
public var slug: String
public var userFacingName: String
public var userFacingDescription: String
public var branches: [ExperimentBranch]
public var referenceBranch: String?
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(slug: String, userFacingName: String, userFacingDescription: String, branches: [ExperimentBranch], referenceBranch: String?) {
self.slug = slug
self.userFacingName = userFacingName
self.userFacingDescription = userFacingDescription
self.branches = branches
self.referenceBranch = referenceBranch
}
}
#if compiler(>=6)
extension AvailableExperiment: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeAvailableExperiment: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AvailableExperiment {
return
try AvailableExperiment(
slug: FfiConverterString.read(from: &buf),
userFacingName: FfiConverterString.read(from: &buf),
userFacingDescription: FfiConverterString.read(from: &buf),
branches: FfiConverterSequenceTypeExperimentBranch.read(from: &buf),
referenceBranch: FfiConverterOptionString.read(from: &buf)
)
}
public static func write(_ value: AvailableExperiment, into buf: inout [UInt8]) {
FfiConverterString.write(value.slug, into: &buf)
FfiConverterString.write(value.userFacingName, into: &buf)
FfiConverterString.write(value.userFacingDescription, into: &buf)
FfiConverterSequenceTypeExperimentBranch.write(value.branches, into: &buf)
FfiConverterOptionString.write(value.referenceBranch, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeAvailableExperiment_lift(_ buf: RustBuffer) throws -> AvailableExperiment {
return try FfiConverterTypeAvailableExperiment.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeAvailableExperiment_lower(_ value: AvailableExperiment) -> RustBuffer {
return FfiConverterTypeAvailableExperiment.lower(value)
}
public struct CalculatedAttributes: Equatable, Hashable {
public var daysSinceInstall: Int32?
public var daysSinceUpdate: Int32?
public var language: String?
public var region: String?
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(daysSinceInstall: Int32?, daysSinceUpdate: Int32?, language: String?, region: String?) {
self.daysSinceInstall = daysSinceInstall
self.daysSinceUpdate = daysSinceUpdate
self.language = language
self.region = region
}
}
#if compiler(>=6)
extension CalculatedAttributes: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCalculatedAttributes: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CalculatedAttributes {
return
try CalculatedAttributes(
daysSinceInstall: FfiConverterOptionInt32.read(from: &buf),
daysSinceUpdate: FfiConverterOptionInt32.read(from: &buf),
language: FfiConverterOptionString.read(from: &buf),
region: FfiConverterOptionString.read(from: &buf)
)
}
public static func write(_ value: CalculatedAttributes, into buf: inout [UInt8]) {
FfiConverterOptionInt32.write(value.daysSinceInstall, into: &buf)
FfiConverterOptionInt32.write(value.daysSinceUpdate, into: &buf)
FfiConverterOptionString.write(value.language, into: &buf)
FfiConverterOptionString.write(value.region, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCalculatedAttributes_lift(_ buf: RustBuffer) throws -> CalculatedAttributes {
return try FfiConverterTypeCalculatedAttributes.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCalculatedAttributes_lower(_ value: CalculatedAttributes) -> RustBuffer {
return FfiConverterTypeCalculatedAttributes.lower(value)
}
public struct DatabaseLoadExtraDef: Equatable, Hashable {
public var corrupt: Bool?
public var error: String?
public var initialVersion: UInt16?
public var migratedVersion: UInt16?
public var migrationError: String?
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(corrupt: Bool?, error: String?, initialVersion: UInt16?, migratedVersion: UInt16?, migrationError: String?) {
self.corrupt = corrupt
self.error = error
self.initialVersion = initialVersion
self.migratedVersion = migratedVersion
self.migrationError = migrationError
}
}
#if compiler(>=6)
extension DatabaseLoadExtraDef: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeDatabaseLoadExtraDef: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DatabaseLoadExtraDef {
return
try DatabaseLoadExtraDef(
corrupt: FfiConverterOptionBool.read(from: &buf),
error: FfiConverterOptionString.read(from: &buf),
initialVersion: FfiConverterOptionUInt16.read(from: &buf),
migratedVersion: FfiConverterOptionUInt16.read(from: &buf),
migrationError: FfiConverterOptionString.read(from: &buf)
)
}
public static func write(_ value: DatabaseLoadExtraDef, into buf: inout [UInt8]) {
FfiConverterOptionBool.write(value.corrupt, into: &buf)
FfiConverterOptionString.write(value.error, into: &buf)
FfiConverterOptionUInt16.write(value.initialVersion, into: &buf)
FfiConverterOptionUInt16.write(value.migratedVersion, into: &buf)
FfiConverterOptionString.write(value.migrationError, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeDatabaseLoadExtraDef_lift(_ buf: RustBuffer) throws -> DatabaseLoadExtraDef {
return try FfiConverterTypeDatabaseLoadExtraDef.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeDatabaseLoadExtraDef_lower(_ value: DatabaseLoadExtraDef) -> RustBuffer {
return FfiConverterTypeDatabaseLoadExtraDef.lower(value)
}
public struct DatabaseMigrationExtraDef: Equatable, Hashable {
public var reason: String
public var fromVersion: UInt16
public var toVersion: UInt16
public var error: String?
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(reason: String, fromVersion: UInt16, toVersion: UInt16, error: String?) {
self.reason = reason
self.fromVersion = fromVersion
self.toVersion = toVersion
self.error = error
}
}
#if compiler(>=6)
extension DatabaseMigrationExtraDef: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeDatabaseMigrationExtraDef: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DatabaseMigrationExtraDef {
return
try DatabaseMigrationExtraDef(
reason: FfiConverterString.read(from: &buf),
fromVersion: FfiConverterUInt16.read(from: &buf),
toVersion: FfiConverterUInt16.read(from: &buf),
error: FfiConverterOptionString.read(from: &buf)
)
}
public static func write(_ value: DatabaseMigrationExtraDef, into buf: inout [UInt8]) {
FfiConverterString.write(value.reason, into: &buf)
FfiConverterUInt16.write(value.fromVersion, into: &buf)
FfiConverterUInt16.write(value.toVersion, into: &buf)
FfiConverterOptionString.write(value.error, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeDatabaseMigrationExtraDef_lift(_ buf: RustBuffer) throws -> DatabaseMigrationExtraDef {
return try FfiConverterTypeDatabaseMigrationExtraDef.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeDatabaseMigrationExtraDef_lower(_ value: DatabaseMigrationExtraDef) -> RustBuffer {
return FfiConverterTypeDatabaseMigrationExtraDef.lower(value)
}
public struct EnrolledExperiment: Equatable, Hashable {
public var featureIds: [String]
public var slug: String
public var userFacingName: String
public var userFacingDescription: String
public var branchSlug: String
public var isRollout: Bool
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(featureIds: [String], slug: String, userFacingName: String, userFacingDescription: String, branchSlug: String, isRollout: Bool) {
self.featureIds = featureIds
self.slug = slug
self.userFacingName = userFacingName
self.userFacingDescription = userFacingDescription
self.branchSlug = branchSlug
self.isRollout = isRollout
}
}
#if compiler(>=6)
extension EnrolledExperiment: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeEnrolledExperiment: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> EnrolledExperiment {
return
try EnrolledExperiment(
featureIds: FfiConverterSequenceString.read(from: &buf),
slug: FfiConverterString.read(from: &buf),
userFacingName: FfiConverterString.read(from: &buf),
userFacingDescription: FfiConverterString.read(from: &buf),
branchSlug: FfiConverterString.read(from: &buf),
isRollout: FfiConverterBool.read(from: &buf)
)
}
public static func write(_ value: EnrolledExperiment, into buf: inout [UInt8]) {
FfiConverterSequenceString.write(value.featureIds, into: &buf)
FfiConverterString.write(value.slug, into: &buf)
FfiConverterString.write(value.userFacingName, into: &buf)
FfiConverterString.write(value.userFacingDescription, into: &buf)
FfiConverterString.write(value.branchSlug, into: &buf)
FfiConverterBool.write(value.isRollout, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeEnrolledExperiment_lift(_ buf: RustBuffer) throws -> EnrolledExperiment {
return try FfiConverterTypeEnrolledExperiment.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeEnrolledExperiment_lower(_ value: EnrolledExperiment) -> RustBuffer {
return FfiConverterTypeEnrolledExperiment.lower(value)
}
public struct EnrollmentChangeEvent: Equatable, Hashable {
public var experimentSlug: String
public var branchSlug: String
public var reason: String?
public var change: EnrollmentChangeEventType
public var featureIds: [String]
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(experimentSlug: String, branchSlug: String, reason: String?, change: EnrollmentChangeEventType, featureIds: [String]) {
self.experimentSlug = experimentSlug
self.branchSlug = branchSlug
self.reason = reason
self.change = change
self.featureIds = featureIds
}
}
#if compiler(>=6)
extension EnrollmentChangeEvent: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeEnrollmentChangeEvent: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> EnrollmentChangeEvent {
return
try EnrollmentChangeEvent(
experimentSlug: FfiConverterString.read(from: &buf),
branchSlug: FfiConverterString.read(from: &buf),
reason: FfiConverterOptionString.read(from: &buf),
change: FfiConverterTypeEnrollmentChangeEventType.read(from: &buf),
featureIds: FfiConverterSequenceString.read(from: &buf)
)
}
public static func write(_ value: EnrollmentChangeEvent, into buf: inout [UInt8]) {
FfiConverterString.write(value.experimentSlug, into: &buf)
FfiConverterString.write(value.branchSlug, into: &buf)
FfiConverterOptionString.write(value.reason, into: &buf)
FfiConverterTypeEnrollmentChangeEventType.write(value.change, into: &buf)
FfiConverterSequenceString.write(value.featureIds, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeEnrollmentChangeEvent_lift(_ buf: RustBuffer) throws -> EnrollmentChangeEvent {
return try FfiConverterTypeEnrollmentChangeEvent.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeEnrollmentChangeEvent_lower(_ value: EnrollmentChangeEvent) -> RustBuffer {
return FfiConverterTypeEnrollmentChangeEvent.lower(value)
}
public struct EnrollmentSlugs: Equatable, Hashable {
public var slug: String
public var branchSlug: String
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(slug: String, branchSlug: String) {
self.slug = slug
self.branchSlug = branchSlug
}
}
#if compiler(>=6)
extension EnrollmentSlugs: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeEnrollmentSlugs: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> EnrollmentSlugs {
return
try EnrollmentSlugs(
slug: FfiConverterString.read(from: &buf),
branchSlug: FfiConverterString.read(from: &buf)
)
}
public static func write(_ value: EnrollmentSlugs, into buf: inout [UInt8]) {
FfiConverterString.write(value.slug, into: &buf)
FfiConverterString.write(value.branchSlug, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeEnrollmentSlugs_lift(_ buf: RustBuffer) throws -> EnrollmentSlugs {
return try FfiConverterTypeEnrollmentSlugs.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeEnrollmentSlugs_lower(_ value: EnrollmentSlugs) -> RustBuffer {
return FfiConverterTypeEnrollmentSlugs.lower(value)
}
public struct EnrollmentStatusExtraDef: Equatable, Hashable {
public var branch: String?
public var conflictSlug: String?
public var errorString: String?
public var reason: String?
public var slug: String?
public var status: String?
public var prevGeckoPrefStates: [PreviousGeckoPrefState]?
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(branch: String?, conflictSlug: String?, errorString: String?, reason: String?, slug: String?, status: String?, prevGeckoPrefStates: [PreviousGeckoPrefState]?) {
self.branch = branch
self.conflictSlug = conflictSlug
self.errorString = errorString
self.reason = reason
self.slug = slug
self.status = status
self.prevGeckoPrefStates = prevGeckoPrefStates
}
}
#if compiler(>=6)
extension EnrollmentStatusExtraDef: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeEnrollmentStatusExtraDef: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> EnrollmentStatusExtraDef {
return
try EnrollmentStatusExtraDef(
branch: FfiConverterOptionString.read(from: &buf),
conflictSlug: FfiConverterOptionString.read(from: &buf),
errorString: FfiConverterOptionString.read(from: &buf),
reason: FfiConverterOptionString.read(from: &buf),
slug: FfiConverterOptionString.read(from: &buf),
status: FfiConverterOptionString.read(from: &buf),
prevGeckoPrefStates: FfiConverterOptionSequenceTypePreviousGeckoPrefState.read(from: &buf)
)
}
public static func write(_ value: EnrollmentStatusExtraDef, into buf: inout [UInt8]) {
FfiConverterOptionString.write(value.branch, into: &buf)
FfiConverterOptionString.write(value.conflictSlug, into: &buf)
FfiConverterOptionString.write(value.errorString, into: &buf)
FfiConverterOptionString.write(value.reason, into: &buf)
FfiConverterOptionString.write(value.slug, into: &buf)
FfiConverterOptionString.write(value.status, into: &buf)
FfiConverterOptionSequenceTypePreviousGeckoPrefState.write(value.prevGeckoPrefStates, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeEnrollmentStatusExtraDef_lift(_ buf: RustBuffer) throws -> EnrollmentStatusExtraDef {
return try FfiConverterTypeEnrollmentStatusExtraDef.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeEnrollmentStatusExtraDef_lower(_ value: EnrollmentStatusExtraDef) -> RustBuffer {
return FfiConverterTypeEnrollmentStatusExtraDef.lower(value)
}
public struct ExperimentBranch: Equatable, Hashable {
public var slug: String
public var ratio: Int32
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(slug: String, ratio: Int32) {
self.slug = slug
self.ratio = ratio
}
}
#if compiler(>=6)
extension ExperimentBranch: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeExperimentBranch: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ExperimentBranch {
return
try ExperimentBranch(
slug: FfiConverterString.read(from: &buf),
ratio: FfiConverterInt32.read(from: &buf)
)
}
public static func write(_ value: ExperimentBranch, into buf: inout [UInt8]) {
FfiConverterString.write(value.slug, into: &buf)
FfiConverterInt32.write(value.ratio, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeExperimentBranch_lift(_ buf: RustBuffer) throws -> ExperimentBranch {
return try FfiConverterTypeExperimentBranch.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeExperimentBranch_lower(_ value: ExperimentBranch) -> RustBuffer {
return FfiConverterTypeExperimentBranch.lower(value)
}
public struct FeatureExposureExtraDef: Equatable, Hashable {
public var branch: String?
public var slug: String
public var featureId: String
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(branch: String?, slug: String, featureId: String) {
self.branch = branch
self.slug = slug
self.featureId = featureId
}
}
#if compiler(>=6)
extension FeatureExposureExtraDef: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeFeatureExposureExtraDef: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FeatureExposureExtraDef {
return
try FeatureExposureExtraDef(
branch: FfiConverterOptionString.read(from: &buf),
slug: FfiConverterString.read(from: &buf),
featureId: FfiConverterString.read(from: &buf)
)
}
public static func write(_ value: FeatureExposureExtraDef, into buf: inout [UInt8]) {
FfiConverterOptionString.write(value.branch, into: &buf)
FfiConverterString.write(value.slug, into: &buf)
FfiConverterString.write(value.featureId, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFeatureExposureExtraDef_lift(_ buf: RustBuffer) throws -> FeatureExposureExtraDef {
return try FfiConverterTypeFeatureExposureExtraDef.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFeatureExposureExtraDef_lower(_ value: FeatureExposureExtraDef) -> RustBuffer {
return FfiConverterTypeFeatureExposureExtraDef.lower(value)
}
public struct FirefoxLabsEnrollResult: Equatable, Hashable {
public var status: FirefoxLabsEnrollStatus
public var enrollmentChangeEvents: [EnrollmentChangeEvent]
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(status: FirefoxLabsEnrollStatus, enrollmentChangeEvents: [EnrollmentChangeEvent]) {
self.status = status
self.enrollmentChangeEvents = enrollmentChangeEvents
}
}
#if compiler(>=6)
extension FirefoxLabsEnrollResult: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeFirefoxLabsEnrollResult: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FirefoxLabsEnrollResult {
return
try FirefoxLabsEnrollResult(
status: FfiConverterTypeFirefoxLabsEnrollStatus.read(from: &buf),
enrollmentChangeEvents: FfiConverterSequenceTypeEnrollmentChangeEvent.read(from: &buf)
)
}
public static func write(_ value: FirefoxLabsEnrollResult, into buf: inout [UInt8]) {
FfiConverterTypeFirefoxLabsEnrollStatus.write(value.status, into: &buf)
FfiConverterSequenceTypeEnrollmentChangeEvent.write(value.enrollmentChangeEvents, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFirefoxLabsEnrollResult_lift(_ buf: RustBuffer) throws -> FirefoxLabsEnrollResult {
return try FfiConverterTypeFirefoxLabsEnrollResult.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFirefoxLabsEnrollResult_lower(_ value: FirefoxLabsEnrollResult) -> RustBuffer {
return FfiConverterTypeFirefoxLabsEnrollResult.lower(value)
}
public struct FirefoxLabsMetadata: Equatable, Hashable {
public var slug: String
public var enrolled: Bool
public var titleStringId: String
public var descriptionStringId: String
public var requiresRestart: Bool
public var feedbackUrl: String?
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(slug: String, enrolled: Bool, titleStringId: String, descriptionStringId: String, requiresRestart: Bool, feedbackUrl: String?) {
self.slug = slug
self.enrolled = enrolled
self.titleStringId = titleStringId
self.descriptionStringId = descriptionStringId
self.requiresRestart = requiresRestart
self.feedbackUrl = feedbackUrl
}
}
#if compiler(>=6)
extension FirefoxLabsMetadata: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeFirefoxLabsMetadata: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FirefoxLabsMetadata {
return
try FirefoxLabsMetadata(
slug: FfiConverterString.read(from: &buf),
enrolled: FfiConverterBool.read(from: &buf),
titleStringId: FfiConverterString.read(from: &buf),
descriptionStringId: FfiConverterString.read(from: &buf),
requiresRestart: FfiConverterBool.read(from: &buf),
feedbackUrl: FfiConverterOptionString.read(from: &buf)
)
}
public static func write(_ value: FirefoxLabsMetadata, into buf: inout [UInt8]) {
FfiConverterString.write(value.slug, into: &buf)
FfiConverterBool.write(value.enrolled, into: &buf)
FfiConverterString.write(value.titleStringId, into: &buf)
FfiConverterString.write(value.descriptionStringId, into: &buf)
FfiConverterBool.write(value.requiresRestart, into: &buf)
FfiConverterOptionString.write(value.feedbackUrl, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFirefoxLabsMetadata_lift(_ buf: RustBuffer) throws -> FirefoxLabsMetadata {
return try FfiConverterTypeFirefoxLabsMetadata.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFirefoxLabsMetadata_lower(_ value: FirefoxLabsMetadata) -> RustBuffer {
return FfiConverterTypeFirefoxLabsMetadata.lower(value)
}
public struct FirefoxLabsUnenrollResult: Equatable, Hashable {
public var status: FirefoxLabsUnenrollStatus
public var enrollmentChangeEvents: [EnrollmentChangeEvent]
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(status: FirefoxLabsUnenrollStatus, enrollmentChangeEvents: [EnrollmentChangeEvent]) {
self.status = status
self.enrollmentChangeEvents = enrollmentChangeEvents
}
}
#if compiler(>=6)
extension FirefoxLabsUnenrollResult: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeFirefoxLabsUnenrollResult: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FirefoxLabsUnenrollResult {
return
try FirefoxLabsUnenrollResult(
status: FfiConverterTypeFirefoxLabsUnenrollStatus.read(from: &buf),
enrollmentChangeEvents: FfiConverterSequenceTypeEnrollmentChangeEvent.read(from: &buf)
)
}
public static func write(_ value: FirefoxLabsUnenrollResult, into buf: inout [UInt8]) {
FfiConverterTypeFirefoxLabsUnenrollStatus.write(value.status, into: &buf)
FfiConverterSequenceTypeEnrollmentChangeEvent.write(value.enrollmentChangeEvents, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFirefoxLabsUnenrollResult_lift(_ buf: RustBuffer) throws -> FirefoxLabsUnenrollResult {
return try FfiConverterTypeFirefoxLabsUnenrollResult.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFirefoxLabsUnenrollResult_lower(_ value: FirefoxLabsUnenrollResult) -> RustBuffer {
return FfiConverterTypeFirefoxLabsUnenrollResult.lower(value)
}
public struct GeckoPref: Equatable, Hashable {
public var pref: String
public var branch: PrefBranch
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(pref: String, branch: PrefBranch) {
self.pref = pref
self.branch = branch
}
}
#if compiler(>=6)
extension GeckoPref: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeGeckoPref: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GeckoPref {
return
try GeckoPref(
pref: FfiConverterString.read(from: &buf),
branch: FfiConverterTypePrefBranch.read(from: &buf)
)
}
public static func write(_ value: GeckoPref, into buf: inout [UInt8]) {
FfiConverterString.write(value.pref, into: &buf)
FfiConverterTypePrefBranch.write(value.branch, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeGeckoPref_lift(_ buf: RustBuffer) throws -> GeckoPref {
return try FfiConverterTypeGeckoPref.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeGeckoPref_lower(_ value: GeckoPref) -> RustBuffer {
return FfiConverterTypeGeckoPref.lower(value)
}
public struct GeckoPrefState: Equatable, Hashable {
public var geckoPref: GeckoPref
public var geckoValue: PrefValue?
public var enrollmentValue: PrefEnrollmentData?
public var isUserSet: Bool
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(geckoPref: GeckoPref, geckoValue: PrefValue?, enrollmentValue: PrefEnrollmentData?, isUserSet: Bool) {
self.geckoPref = geckoPref
self.geckoValue = geckoValue
self.enrollmentValue = enrollmentValue
self.isUserSet = isUserSet
}
}
#if compiler(>=6)
extension GeckoPrefState: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeGeckoPrefState: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GeckoPrefState {
return
try GeckoPrefState(
geckoPref: FfiConverterTypeGeckoPref.read(from: &buf),
geckoValue: FfiConverterOptionTypePrefValue.read(from: &buf),
enrollmentValue: FfiConverterOptionTypePrefEnrollmentData.read(from: &buf),
isUserSet: FfiConverterBool.read(from: &buf)
)
}
public static func write(_ value: GeckoPrefState, into buf: inout [UInt8]) {
FfiConverterTypeGeckoPref.write(value.geckoPref, into: &buf)
FfiConverterOptionTypePrefValue.write(value.geckoValue, into: &buf)
FfiConverterOptionTypePrefEnrollmentData.write(value.enrollmentValue, into: &buf)
FfiConverterBool.write(value.isUserSet, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeGeckoPrefState_lift(_ buf: RustBuffer) throws -> GeckoPrefState {
return try FfiConverterTypeGeckoPrefState.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeGeckoPrefState_lower(_ value: GeckoPrefState) -> RustBuffer {
return FfiConverterTypeGeckoPrefState.lower(value)
}
public struct MalformedFeatureConfigExtraDef: Equatable, Hashable {
public var branch: String?
public var slug: String?
public var featureId: String
public var part: String
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(branch: String?, slug: String?, featureId: String, part: String) {
self.branch = branch
self.slug = slug
self.featureId = featureId
self.part = part
}
}
#if compiler(>=6)
extension MalformedFeatureConfigExtraDef: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeMalformedFeatureConfigExtraDef: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MalformedFeatureConfigExtraDef {
return
try MalformedFeatureConfigExtraDef(
branch: FfiConverterOptionString.read(from: &buf),
slug: FfiConverterOptionString.read(from: &buf),
featureId: FfiConverterString.read(from: &buf),
part: FfiConverterString.read(from: &buf)
)
}
public static func write(_ value: MalformedFeatureConfigExtraDef, into buf: inout [UInt8]) {
FfiConverterOptionString.write(value.branch, into: &buf)
FfiConverterOptionString.write(value.slug, into: &buf)
FfiConverterString.write(value.featureId, into: &buf)
FfiConverterString.write(value.part, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeMalformedFeatureConfigExtraDef_lift(_ buf: RustBuffer) throws -> MalformedFeatureConfigExtraDef {
return try FfiConverterTypeMalformedFeatureConfigExtraDef.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeMalformedFeatureConfigExtraDef_lower(_ value: MalformedFeatureConfigExtraDef) -> RustBuffer {
return FfiConverterTypeMalformedFeatureConfigExtraDef.lower(value)
}
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
public var value: PrefValue?
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(pref: String, branch: PrefBranch, value: PrefValue?) {
self.pref = pref
self.branch = branch
self.value = value
}
}
#if compiler(>=6)
extension OriginalGeckoPref: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeOriginalGeckoPref: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OriginalGeckoPref {
return
try OriginalGeckoPref(
pref: FfiConverterString.read(from: &buf),
branch: FfiConverterTypePrefBranch.read(from: &buf),
value: FfiConverterOptionTypePrefValue.read(from: &buf)
)
}
public static func write(_ value: OriginalGeckoPref, into buf: inout [UInt8]) {
FfiConverterString.write(value.pref, into: &buf)
FfiConverterTypePrefBranch.write(value.branch, into: &buf)
FfiConverterOptionTypePrefValue.write(value.value, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeOriginalGeckoPref_lift(_ buf: RustBuffer) throws -> OriginalGeckoPref {
return try FfiConverterTypeOriginalGeckoPref.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeOriginalGeckoPref_lower(_ value: OriginalGeckoPref) -> RustBuffer {
return FfiConverterTypeOriginalGeckoPref.lower(value)
}
public struct PrefEnrollmentData: Equatable, Hashable {
public var experimentSlug: String
public var prefValue: PrefValue
public var featureId: String
public var variable: String
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(experimentSlug: String, prefValue: PrefValue, featureId: String, variable: String) {
self.experimentSlug = experimentSlug
self.prefValue = prefValue
self.featureId = featureId
self.variable = variable
}
}
#if compiler(>=6)
extension PrefEnrollmentData: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypePrefEnrollmentData: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PrefEnrollmentData {
return
try PrefEnrollmentData(
experimentSlug: FfiConverterString.read(from: &buf),
prefValue: FfiConverterTypePrefValue.read(from: &buf),
featureId: FfiConverterString.read(from: &buf),
variable: FfiConverterString.read(from: &buf)
)
}
public static func write(_ value: PrefEnrollmentData, into buf: inout [UInt8]) {
FfiConverterString.write(value.experimentSlug, into: &buf)
FfiConverterTypePrefValue.write(value.prefValue, into: &buf)
FfiConverterString.write(value.featureId, into: &buf)
FfiConverterString.write(value.variable, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePrefEnrollmentData_lift(_ buf: RustBuffer) throws -> PrefEnrollmentData {
return try FfiConverterTypePrefEnrollmentData.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePrefEnrollmentData_lower(_ value: PrefEnrollmentData) -> RustBuffer {
return FfiConverterTypePrefEnrollmentData.lower(value)
}
public struct PreviousGeckoPrefState: Equatable, Hashable {
public var originalValue: OriginalGeckoPref
public var featureId: String
public var variable: String
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(originalValue: OriginalGeckoPref, featureId: String, variable: String) {
self.originalValue = originalValue
self.featureId = featureId
self.variable = variable
}
}
#if compiler(>=6)
extension PreviousGeckoPrefState: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypePreviousGeckoPrefState: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PreviousGeckoPrefState {
return
try PreviousGeckoPrefState(
originalValue: FfiConverterTypeOriginalGeckoPref.read(from: &buf),
featureId: FfiConverterString.read(from: &buf),
variable: FfiConverterString.read(from: &buf)
)
}
public static func write(_ value: PreviousGeckoPrefState, into buf: inout [UInt8]) {
FfiConverterTypeOriginalGeckoPref.write(value.originalValue, into: &buf)
FfiConverterString.write(value.featureId, into: &buf)
FfiConverterString.write(value.variable, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePreviousGeckoPrefState_lift(_ buf: RustBuffer) throws -> PreviousGeckoPrefState {
return try FfiConverterTypePreviousGeckoPrefState.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePreviousGeckoPrefState_lower(_ value: PreviousGeckoPrefState) -> RustBuffer {
return FfiConverterTypePreviousGeckoPrefState.lower(value)
}
public enum EnrollmentChangeEventType: Equatable, Hashable {
case enrollment
case enrollFailed
case disqualification
case unenrollment
case unenrollFailed
}
#if compiler(>=6)
extension EnrollmentChangeEventType: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeEnrollmentChangeEventType: FfiConverterRustBuffer {
typealias SwiftType = EnrollmentChangeEventType
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> EnrollmentChangeEventType {
let variant: Int32 = try readInt(&buf)
switch variant {
case 1: return .enrollment
case 2: return .enrollFailed
case 3: return .disqualification
case 4: return .unenrollment
case 5: return .unenrollFailed
default: throw UniffiInternalError.unexpectedEnumCase
}
}
public static func write(_ value: EnrollmentChangeEventType, into buf: inout [UInt8]) {
switch value {
case .enrollment:
writeInt(&buf, Int32(1))
case .enrollFailed:
writeInt(&buf, Int32(2))
case .disqualification:
writeInt(&buf, Int32(3))
case .unenrollment:
writeInt(&buf, Int32(4))
case .unenrollFailed:
writeInt(&buf, Int32(5))
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeEnrollmentChangeEventType_lift(_ buf: RustBuffer) throws -> EnrollmentChangeEventType {
return try FfiConverterTypeEnrollmentChangeEventType.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeEnrollmentChangeEventType_lower(_ value: EnrollmentChangeEventType) -> RustBuffer {
return FfiConverterTypeEnrollmentChangeEventType.lower(value)
}
public enum FirefoxLabsEnrollStatus: Equatable, Hashable {
case enrolled
case alreadyEnrolled
case noExperiment
case notFirefoxLabsOptIn
case featureConflict
case error
}
#if compiler(>=6)
extension FirefoxLabsEnrollStatus: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeFirefoxLabsEnrollStatus: FfiConverterRustBuffer {
typealias SwiftType = FirefoxLabsEnrollStatus
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FirefoxLabsEnrollStatus {
let variant: Int32 = try readInt(&buf)
switch variant {
case 1: return .enrolled
case 2: return .alreadyEnrolled
case 3: return .noExperiment
case 4: return .notFirefoxLabsOptIn
case 5: return .featureConflict
case 6: return .error
default: throw UniffiInternalError.unexpectedEnumCase
}
}
public static func write(_ value: FirefoxLabsEnrollStatus, into buf: inout [UInt8]) {
switch value {
case .enrolled:
writeInt(&buf, Int32(1))
case .alreadyEnrolled:
writeInt(&buf, Int32(2))
case .noExperiment:
writeInt(&buf, Int32(3))
case .notFirefoxLabsOptIn:
writeInt(&buf, Int32(4))
case .featureConflict:
writeInt(&buf, Int32(5))
case .error:
writeInt(&buf, Int32(6))
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFirefoxLabsEnrollStatus_lift(_ buf: RustBuffer) throws -> FirefoxLabsEnrollStatus {
return try FfiConverterTypeFirefoxLabsEnrollStatus.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFirefoxLabsEnrollStatus_lower(_ value: FirefoxLabsEnrollStatus) -> RustBuffer {
return FfiConverterTypeFirefoxLabsEnrollStatus.lower(value)
}
public enum FirefoxLabsUnenrollStatus: Equatable, Hashable {
case unenrolled
case alreadyUnenrolled
case noExperiment
case notFirefoxLabsOptIn
case error
}
#if compiler(>=6)
extension FirefoxLabsUnenrollStatus: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeFirefoxLabsUnenrollStatus: FfiConverterRustBuffer {
typealias SwiftType = FirefoxLabsUnenrollStatus
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FirefoxLabsUnenrollStatus {
let variant: Int32 = try readInt(&buf)
switch variant {
case 1: return .unenrolled
case 2: return .alreadyUnenrolled
case 3: return .noExperiment
case 4: return .notFirefoxLabsOptIn
case 5: return .error
default: throw UniffiInternalError.unexpectedEnumCase
}
}
public static func write(_ value: FirefoxLabsUnenrollStatus, into buf: inout [UInt8]) {
switch value {
case .unenrolled:
writeInt(&buf, Int32(1))
case .alreadyUnenrolled:
writeInt(&buf, Int32(2))
case .noExperiment:
writeInt(&buf, Int32(3))
case .notFirefoxLabsOptIn:
writeInt(&buf, Int32(4))
case .error:
writeInt(&buf, Int32(5))
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFirefoxLabsUnenrollStatus_lift(_ buf: RustBuffer) throws -> FirefoxLabsUnenrollStatus {
return try FfiConverterTypeFirefoxLabsUnenrollStatus.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFirefoxLabsUnenrollStatus_lower(_ value: FirefoxLabsUnenrollStatus) -> RustBuffer {
return FfiConverterTypeFirefoxLabsUnenrollStatus.lower(value)
}
public
enum NimbusError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError {
case InvalidPersistedData(message: String)
case RkvError(message: String)
case IoError(message: String)
case JsonError(message: String)
case EvaluationError(message: String)
case InvalidExpression(message: String)
case InvalidFraction(message: String)
case TryFromSliceError(message: String)
case EmptyRatiosError(message: String)
case OutOfBoundsError(message: String)
case UrlParsingError(message: String)
case UuidError(message: String)
case InvalidExperimentFormat(message: String)
case InvalidPath(message: String)
case InternalError(message: String)
case NoSuchExperiment(message: String)
case NoSuchBranch(message: String)
case DatabaseNotReady(message: String)
case VersionParsingError(message: String)
case BehaviorError(message: String)
case TryFromIntError(message: String)
case ParseIntError(message: String)
case TransformParameterError(message: String)
case ClientError(message: String)
case UniFfiCallbackError(message: String)
case RegexError(message: String)
public var errorDescription: String? {
String(reflecting: self)
}
}
#if compiler(>=6)
extension NimbusError: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeNimbusError: FfiConverterRustBuffer {
typealias SwiftType = NimbusError
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> NimbusError {
let variant: Int32 = try readInt(&buf)
switch variant {
case 1: return .InvalidPersistedData(
message: try FfiConverterString.read(from: &buf)
)
case 2: return .RkvError(
message: try FfiConverterString.read(from: &buf)
)
case 3: return .IoError(
message: try FfiConverterString.read(from: &buf)
)
case 4: return .JsonError(
message: try FfiConverterString.read(from: &buf)
)
case 5: return .EvaluationError(
message: try FfiConverterString.read(from: &buf)
)
case 6: return .InvalidExpression(
message: try FfiConverterString.read(from: &buf)
)
case 7: return .InvalidFraction(
message: try FfiConverterString.read(from: &buf)
)
case 8: return .TryFromSliceError(
message: try FfiConverterString.read(from: &buf)
)
case 9: return .EmptyRatiosError(
message: try FfiConverterString.read(from: &buf)
)
case 10: return .OutOfBoundsError(
message: try FfiConverterString.read(from: &buf)
)
case 11: return .UrlParsingError(
message: try FfiConverterString.read(from: &buf)
)
case 12: return .UuidError(
message: try FfiConverterString.read(from: &buf)
)
case 13: return .InvalidExperimentFormat(
message: try FfiConverterString.read(from: &buf)
)
case 14: return .InvalidPath(
message: try FfiConverterString.read(from: &buf)
)
case 15: return .InternalError(
message: try FfiConverterString.read(from: &buf)
)
case 16: return .NoSuchExperiment(
message: try FfiConverterString.read(from: &buf)
)
case 17: return .NoSuchBranch(
message: try FfiConverterString.read(from: &buf)
)
case 18: return .DatabaseNotReady(
message: try FfiConverterString.read(from: &buf)
)
case 19: return .VersionParsingError(
message: try FfiConverterString.read(from: &buf)
)
case 20: return .BehaviorError(
message: try FfiConverterString.read(from: &buf)
)
case 21: return .TryFromIntError(
message: try FfiConverterString.read(from: &buf)
)
case 22: return .ParseIntError(
message: try FfiConverterString.read(from: &buf)
)
case 23: return .TransformParameterError(
message: try FfiConverterString.read(from: &buf)
)
case 24: return .ClientError(
message: try FfiConverterString.read(from: &buf)
)
case 25: return .UniFfiCallbackError(
message: try FfiConverterString.read(from: &buf)
)
case 26: return .RegexError(
message: try FfiConverterString.read(from: &buf)
)
default: throw UniffiInternalError.unexpectedEnumCase
}
}
public static func write(_ value: NimbusError, into buf: inout [UInt8]) {
switch value {
case .InvalidPersistedData(_ /* message is ignored*/):
writeInt(&buf, Int32(1))
case .RkvError(_ /* message is ignored*/):
writeInt(&buf, Int32(2))
case .IoError(_ /* message is ignored*/):
writeInt(&buf, Int32(3))
case .JsonError(_ /* message is ignored*/):
writeInt(&buf, Int32(4))
case .EvaluationError(_ /* message is ignored*/):
writeInt(&buf, Int32(5))
case .InvalidExpression(_ /* message is ignored*/):
writeInt(&buf, Int32(6))
case .InvalidFraction(_ /* message is ignored*/):
writeInt(&buf, Int32(7))
case .TryFromSliceError(_ /* message is ignored*/):
writeInt(&buf, Int32(8))
case .EmptyRatiosError(_ /* message is ignored*/):
writeInt(&buf, Int32(9))
case .OutOfBoundsError(_ /* message is ignored*/):
writeInt(&buf, Int32(10))
case .UrlParsingError(_ /* message is ignored*/):
writeInt(&buf, Int32(11))
case .UuidError(_ /* message is ignored*/):
writeInt(&buf, Int32(12))
case .InvalidExperimentFormat(_ /* message is ignored*/):
writeInt(&buf, Int32(13))
case .InvalidPath(_ /* message is ignored*/):
writeInt(&buf, Int32(14))
case .InternalError(_ /* message is ignored*/):
writeInt(&buf, Int32(15))
case .NoSuchExperiment(_ /* message is ignored*/):
writeInt(&buf, Int32(16))
case .NoSuchBranch(_ /* message is ignored*/):
writeInt(&buf, Int32(17))
case .DatabaseNotReady(_ /* message is ignored*/):
writeInt(&buf, Int32(18))
case .VersionParsingError(_ /* message is ignored*/):
writeInt(&buf, Int32(19))
case .BehaviorError(_ /* message is ignored*/):
writeInt(&buf, Int32(20))
case .TryFromIntError(_ /* message is ignored*/):
writeInt(&buf, Int32(21))
case .ParseIntError(_ /* message is ignored*/):
writeInt(&buf, Int32(22))
case .TransformParameterError(_ /* message is ignored*/):
writeInt(&buf, Int32(23))
case .ClientError(_ /* message is ignored*/):
writeInt(&buf, Int32(24))
case .UniFfiCallbackError(_ /* message is ignored*/):
writeInt(&buf, Int32(25))
case .RegexError(_ /* message is ignored*/):
writeInt(&buf, Int32(26))
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeNimbusError_lift(_ buf: RustBuffer) throws -> NimbusError {
return try FfiConverterTypeNimbusError.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeNimbusError_lower(_ value: NimbusError) -> RustBuffer {
return FfiConverterTypeNimbusError.lower(value)
}
public enum PrefBranch: Equatable, Hashable {
case `default`
case user
}
#if compiler(>=6)
extension PrefBranch: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypePrefBranch: FfiConverterRustBuffer {
typealias SwiftType = PrefBranch
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PrefBranch {
let variant: Int32 = try readInt(&buf)
switch variant {
case 1: return .`default`
case 2: return .user
default: throw UniffiInternalError.unexpectedEnumCase
}
}
public static func write(_ value: PrefBranch, into buf: inout [UInt8]) {
switch value {
case .`default`:
writeInt(&buf, Int32(1))
case .user:
writeInt(&buf, Int32(2))
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePrefBranch_lift(_ buf: RustBuffer) throws -> PrefBranch {
return try FfiConverterTypePrefBranch.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePrefBranch_lower(_ value: PrefBranch) -> RustBuffer {
return FfiConverterTypePrefBranch.lower(value)
}
public enum PrefUnenrollReason: Equatable, Hashable {
case changed
case failedToSet
}
#if compiler(>=6)
extension PrefUnenrollReason: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypePrefUnenrollReason: FfiConverterRustBuffer {
typealias SwiftType = PrefUnenrollReason
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PrefUnenrollReason {
let variant: Int32 = try readInt(&buf)
switch variant {
case 1: return .changed
case 2: return .failedToSet
default: throw UniffiInternalError.unexpectedEnumCase
}
}
public static func write(_ value: PrefUnenrollReason, into buf: inout [UInt8]) {
switch value {
case .changed:
writeInt(&buf, Int32(1))
case .failedToSet:
writeInt(&buf, Int32(2))
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePrefUnenrollReason_lift(_ buf: RustBuffer) throws -> PrefUnenrollReason {
return try FfiConverterTypePrefUnenrollReason.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePrefUnenrollReason_lower(_ value: PrefUnenrollReason) -> RustBuffer {
return FfiConverterTypePrefUnenrollReason.lower(value)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionUInt16: FfiConverterRustBuffer {
typealias SwiftType = UInt16?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterUInt16.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 FfiConverterUInt16.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionInt32: FfiConverterRustBuffer {
typealias SwiftType = Int32?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterInt32.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 FfiConverterInt32.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionInt64: FfiConverterRustBuffer {
typealias SwiftType = Int64?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterInt64.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 FfiConverterInt64.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionBool: FfiConverterRustBuffer {
typealias SwiftType = Bool?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterBool.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 FfiConverterBool.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
typealias SwiftType = String?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterString.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 FfiConverterString.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypeGeckoPrefHandler: FfiConverterRustBuffer {
typealias SwiftType = GeckoPrefHandler?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterTypeGeckoPrefHandler.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 FfiConverterTypeGeckoPrefHandler.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypeRecordedContext: FfiConverterRustBuffer {
typealias SwiftType = RecordedContext?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterTypeRecordedContext.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 FfiConverterTypeRecordedContext.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypeNimbusServerSettings: FfiConverterRustBuffer {
typealias SwiftType = NimbusServerSettings?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
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 FfiConverterTypeNimbusServerSettings.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypePrefEnrollmentData: FfiConverterRustBuffer {
typealias SwiftType = PrefEnrollmentData?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterTypePrefEnrollmentData.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 FfiConverterTypePrefEnrollmentData.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionSequenceTypePreviousGeckoPrefState: FfiConverterRustBuffer {
typealias SwiftType = [PreviousGeckoPrefState]?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterSequenceTypePreviousGeckoPrefState.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 FfiConverterSequenceTypePreviousGeckoPrefState.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypeJsonObject: FfiConverterRustBuffer {
typealias SwiftType = JsonObject?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterTypeJsonObject.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 FfiConverterTypeJsonObject.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypePrefValue: FfiConverterRustBuffer {
typealias SwiftType = PrefValue?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterTypePrefValue.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 FfiConverterTypePrefValue.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
typealias SwiftType = [String]
public static func write(_ value: [String], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterString.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String] {
let len: Int32 = try readInt(&buf)
var seq = [String]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterString.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeAvailableExperiment: FfiConverterRustBuffer {
typealias SwiftType = [AvailableExperiment]
public static func write(_ value: [AvailableExperiment], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeAvailableExperiment.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AvailableExperiment] {
let len: Int32 = try readInt(&buf)
var seq = [AvailableExperiment]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeAvailableExperiment.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeEnrolledExperiment: FfiConverterRustBuffer {
typealias SwiftType = [EnrolledExperiment]
public static func write(_ value: [EnrolledExperiment], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeEnrolledExperiment.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [EnrolledExperiment] {
let len: Int32 = try readInt(&buf)
var seq = [EnrolledExperiment]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeEnrolledExperiment.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeEnrollmentChangeEvent: FfiConverterRustBuffer {
typealias SwiftType = [EnrollmentChangeEvent]
public static func write(_ value: [EnrollmentChangeEvent], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeEnrollmentChangeEvent.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [EnrollmentChangeEvent] {
let len: Int32 = try readInt(&buf)
var seq = [EnrollmentChangeEvent]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeEnrollmentChangeEvent.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeEnrollmentSlugs: FfiConverterRustBuffer {
typealias SwiftType = [EnrollmentSlugs]
public static func write(_ value: [EnrollmentSlugs], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeEnrollmentSlugs.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [EnrollmentSlugs] {
let len: Int32 = try readInt(&buf)
var seq = [EnrollmentSlugs]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeEnrollmentSlugs.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeEnrollmentStatusExtraDef: FfiConverterRustBuffer {
typealias SwiftType = [EnrollmentStatusExtraDef]
public static func write(_ value: [EnrollmentStatusExtraDef], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeEnrollmentStatusExtraDef.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [EnrollmentStatusExtraDef] {
let len: Int32 = try readInt(&buf)
var seq = [EnrollmentStatusExtraDef]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeEnrollmentStatusExtraDef.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeExperimentBranch: FfiConverterRustBuffer {
typealias SwiftType = [ExperimentBranch]
public static func write(_ value: [ExperimentBranch], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeExperimentBranch.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ExperimentBranch] {
let len: Int32 = try readInt(&buf)
var seq = [ExperimentBranch]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeExperimentBranch.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeFirefoxLabsMetadata: FfiConverterRustBuffer {
typealias SwiftType = [FirefoxLabsMetadata]
public static func write(_ value: [FirefoxLabsMetadata], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeFirefoxLabsMetadata.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [FirefoxLabsMetadata] {
let len: Int32 = try readInt(&buf)
var seq = [FirefoxLabsMetadata]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeFirefoxLabsMetadata.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeGeckoPrefState: FfiConverterRustBuffer {
typealias SwiftType = [GeckoPrefState]
public static func write(_ value: [GeckoPrefState], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeGeckoPrefState.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [GeckoPrefState] {
let len: Int32 = try readInt(&buf)
var seq = [GeckoPrefState]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeGeckoPrefState.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeOriginalGeckoPref: FfiConverterRustBuffer {
typealias SwiftType = [OriginalGeckoPref]
public static func write(_ value: [OriginalGeckoPref], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeOriginalGeckoPref.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [OriginalGeckoPref] {
let len: Int32 = try readInt(&buf)
var seq = [OriginalGeckoPref]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeOriginalGeckoPref.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypePreviousGeckoPrefState: FfiConverterRustBuffer {
typealias SwiftType = [PreviousGeckoPrefState]
public static func write(_ value: [PreviousGeckoPrefState], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypePreviousGeckoPrefState.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PreviousGeckoPrefState] {
let len: Int32 = try readInt(&buf)
var seq = [PreviousGeckoPrefState]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypePreviousGeckoPrefState.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterDictionaryStringDouble: FfiConverterRustBuffer {
public static func write(_ value: [String: Double], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for (key, value) in value {
FfiConverterString.write(key, into: &buf)
FfiConverterDouble.write(value, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String: Double] {
let len: Int32 = try readInt(&buf)
var dict = [String: Double]()
dict.reserveCapacity(Int(len))
for _ in 0..<len {
let key = try FfiConverterString.read(from: &buf)
let value = try FfiConverterDouble.read(from: &buf)
dict[key] = value
}
return dict
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterDictionaryStringString: FfiConverterRustBuffer {
public static func write(_ value: [String: String], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for (key, value) in value {
FfiConverterString.write(key, into: &buf)
FfiConverterString.write(value, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String: String] {
let len: Int32 = try readInt(&buf)
var dict = [String: String]()
dict.reserveCapacity(Int(len))
for _ in 0..<len {
let key = try FfiConverterString.read(from: &buf)
let value = try FfiConverterString.read(from: &buf)
dict[key] = value
}
return dict
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterDictionaryStringTypeGeckoPrefState: FfiConverterRustBuffer {
public static func write(_ value: [String: GeckoPrefState], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for (key, value) in value {
FfiConverterString.write(key, into: &buf)
FfiConverterTypeGeckoPrefState.write(value, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String: GeckoPrefState] {
let len: Int32 = try readInt(&buf)
var dict = [String: GeckoPrefState]()
dict.reserveCapacity(Int(len))
for _ in 0..<len {
let key = try FfiConverterString.read(from: &buf)
let value = try FfiConverterTypeGeckoPrefState.read(from: &buf)
dict[key] = value
}
return dict
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterDictionaryStringDictionaryStringTypeGeckoPrefState: FfiConverterRustBuffer {
public static func write(_ value: [String: [String: GeckoPrefState]], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for (key, value) in value {
FfiConverterString.write(key, into: &buf)
FfiConverterDictionaryStringTypeGeckoPrefState.write(value, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String: [String: GeckoPrefState]] {
let len: Int32 = try readInt(&buf)
var dict = [String: [String: GeckoPrefState]]()
dict.reserveCapacity(Int(len))
for _ in 0..<len {
let key = try FfiConverterString.read(from: &buf)
let value = try FfiConverterDictionaryStringTypeGeckoPrefState.read(from: &buf)
dict[key] = value
}
return dict
}
}
public typealias JsonObject = String
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeJsonObject: FfiConverter {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> JsonObject {
return try FfiConverterString.read(from: &buf)
}
public static func write(_ value: JsonObject, into buf: inout [UInt8]) {
return FfiConverterString.write(value, into: &buf)
}
public static func lift(_ value: RustBuffer) throws -> JsonObject {
return try FfiConverterString.lift(value)
}
public static func lower(_ value: JsonObject) -> RustBuffer {
return FfiConverterString.lower(value)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeJsonObject_lift(_ value: RustBuffer) throws -> JsonObject {
return try FfiConverterTypeJsonObject.lift(value)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeJsonObject_lower(_ value: JsonObject) -> RustBuffer {
return FfiConverterTypeJsonObject.lower(value)
}
public typealias PrefValue = String
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypePrefValue: FfiConverter {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PrefValue {
return try FfiConverterString.read(from: &buf)
}
public static func write(_ value: PrefValue, into buf: inout [UInt8]) {
return FfiConverterString.write(value, into: &buf)
}
public static func lift(_ value: RustBuffer) throws -> PrefValue {
return try FfiConverterString.lift(value)
}
public static func lower(_ value: PrefValue) -> RustBuffer {
return FfiConverterString.lower(value)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePrefValue_lift(_ value: RustBuffer) throws -> PrefValue {
return try FfiConverterTypePrefValue.lift(value)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePrefValue_lower(_ value: PrefValue) -> RustBuffer {
return FfiConverterTypePrefValue.lower(value)
}
/**
* Return the list of active experiments.
*
* Intended to be called in instances where a full Nimbus Client cannot be
* instantiated (e.g., in crash reporting infrastructure).
*/
public func getActiveEnrollments(dbPath: String)throws -> [EnrollmentSlugs] {
return try FfiConverterSequenceTypeEnrollmentSlugs.lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_func_get_active_enrollments(
FfiConverterString.lower(dbPath),uniffiCallStatus
)
})
}
/**
*/
public func getCalculatedAttributes(installationDate: Int64?, dbPath: String, locale: String)throws -> CalculatedAttributes {
return try FfiConverterTypeCalculatedAttributes_lift(try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_func_get_calculated_attributes(
FfiConverterOptionInt64.lower(installationDate),
FfiConverterString.lower(dbPath),
FfiConverterString.lower(locale),uniffiCallStatus
)
})
}
/**
* A test utility used to validate event queries against the jexl evaluator.
*
* This method should only be used in tests.
*/
public func validateEventQueries(recordedContext: RecordedContext)throws {try rustCallWithError(FfiConverterTypeNimbusError_lift) {
uniffiCallStatus in
uniffi_nimbus_fn_func_validate_event_queries(
FfiConverterTypeRecordedContext_lower(recordedContext),uniffiCallStatus
)
}
}
private enum InitializationResult {
case ok
case contractVersionMismatch
case apiChecksumMismatch
}
// Use a global variable to perform the versioning checks. Swift ensures that
// the code inside is only computed once.
private let initializationResult: InitializationResult = {
// Get the bindings contract version from our ComponentInterface
let bindings_contract_version = 30
// Get the scaffolding contract version by calling the into the dylib
let scaffolding_contract_version = ffi_nimbus_uniffi_contract_version()
if bindings_contract_version != scaffolding_contract_version {
return InitializationResult.contractVersionMismatch
}
if (uniffi_nimbus_checksum_func_get_active_enrollments() != 61568) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_func_get_calculated_attributes() != 48636) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_func_validate_event_queries() != 54480) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_geckoprefhandler_get_prefs_with_state() != 57920) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_geckoprefhandler_set_gecko_prefs_original_values() != 49053) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_geckoprefhandler_set_gecko_prefs_state() != 24434) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_metricshandler_record_database_load() != 41701) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_metricshandler_record_database_migration() != 30298) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_metricshandler_record_enrollment_statuses() != 59810) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_metricshandler_record_feature_activation() != 33978) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_metricshandler_record_feature_exposure() != 52324) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_metricshandler_record_malformed_feature_config() != 28930) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_metricshandler_record_rollouts_opt_out() != 61690) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_metricshandler_record_studies_opt_out() != 57758) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_metricshandler_submit_targeting_context() != 53590) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_advance_event_time() != 56101) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_apply_pending_experiments() != 14250) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_clear_events() != 44752) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_create_string_helper() != 58971) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_create_targeting_helper() != 48490) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_dump_state_to_log() != 11961) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_enroll_in_firefox_lab() != 36090) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_fetch_experiments() != 19471) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_get_active_experiments() != 17939) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_get_available_experiments() != 57010) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_get_available_firefox_labs() != 22135) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_get_experiment_branch() != 13577) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_get_experiment_branches() != 17108) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_get_experiment_participation() != 29644) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_get_feature_config_variables() != 21520) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_get_previous_gecko_pref_states() != 4412) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_get_rollout_participation() != 29265) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_initialize() != 5594) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_is_fetch_enabled() != 23770) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_opt_in_with_branch() != 51396) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_opt_out() != 29954) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_record_event() != 48537) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_record_feature_exposure() != 34089) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_record_malformed_feature_config() != 7534) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_record_past_event() != 34127) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_register_previous_gecko_pref_states() != 62339) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_reset_enrollments() != 11263) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_reset_telemetry_identifiers() != 44605) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_set_experiment_participation() != 9229) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_set_experiments_locally() != 12966) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_set_fetch_enabled() != 24070) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_set_rollout_participation() != 53193) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_unenroll_for_gecko_pref() != 10854) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_unenroll_from_all_firefox_labs() != 43184) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusclient_unenroll_from_firefox_lab() != 47442) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusstringhelper_get_uuid() != 50935) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbusstringhelper_string_format() != 35168) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbustargetinghelper_eval_jexl() != 33153) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_nimbustargetinghelper_eval_jexl_debug() != 38986) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_recordedcontext_get_event_queries() != 58067) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_recordedcontext_record() != 37535) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_recordedcontext_set_event_query_values() != 21977) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_method_recordedcontext_to_json() != 16871) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_nimbus_checksum_constructor_nimbusclient_new() != 17149) {
return InitializationResult.apiChecksumMismatch
}
uniffiCallbackInitGeckoPrefHandler()
uniffiCallbackInitMetricsHandler()
uniffiCallbackInitRecordedContext()
uniffiEnsureRemoteSettingsInitialized()
return InitializationResult.ok
}()
// Make the ensure init function public so that other modules which have external type references to
// our types can call it.
public func uniffiEnsureNimbusInitialized() {
switch initializationResult {
case .ok:
break
case .contractVersionMismatch:
fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project")
case .apiChecksumMismatch:
fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
}
// swiftlint:enable all