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_merino_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_merino_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 {
uniffiEnsureMerinoInitialized()
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.
#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 FfiConverterUInt32: FfiConverterPrimitive {
typealias FfiType = UInt32
typealias SwiftType = UInt32
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt32 {
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 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)
}
}
/**
* Client for fetching curated recommendations from the Merino service.
*
* Construct using [`CuratedRecommendationsClient::new`] with a
* [`CuratedRecommendationsConfig`], then call
* [`get_curated_recommendations`](CuratedRecommendationsClient::get_curated_recommendations)
* to fetch recommendations.
*/
public protocol CuratedRecommendationsClientProtocol: AnyObject, Sendable {
/**
* Fetches curated recommendations from the Merino API.
*/
func getCuratedRecommendations(request: CuratedRecommendationsRequest) throws -> CuratedRecommendationsResponse
}
/**
* Client for fetching curated recommendations from the Merino service.
*
* Construct using [`CuratedRecommendationsClient::new`] with a
* [`CuratedRecommendationsConfig`], then call
* [`get_curated_recommendations`](CuratedRecommendationsClient::get_curated_recommendations)
* to fetch recommendations.
*/
open class CuratedRecommendationsClient: CuratedRecommendationsClientProtocol, @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_merino_fn_clone_curatedrecommendationsclient(self.handle, $0) }
}
/**
* Creates a new client from the given configuration.
*/
public convenience init(config: CuratedRecommendationsConfig)throws {
let handle =
try rustCallWithError(FfiConverterTypeCuratedRecommendationsApiError_lift) {
uniffiCallStatus in
uniffi_merino_fn_constructor_curatedrecommendationsclient_new(
FfiConverterTypeCuratedRecommendationsConfig_lower(config),uniffiCallStatus
)
}
self.init(unsafeFromHandle: handle)
}
deinit {
if handle == 0 {
// Mock objects have handle=0 don't try to free them
return
}
try! rustCall { uniffi_merino_fn_free_curatedrecommendationsclient(handle, $0) }
}
/**
* Fetches curated recommendations from the Merino API.
*/
open func getCuratedRecommendations(request: CuratedRecommendationsRequest)throws -> CuratedRecommendationsResponse {
return try FfiConverterTypeCuratedRecommendationsResponse_lift(try rustCallWithError(FfiConverterTypeCuratedRecommendationsApiError_lift) {
uniffiCallStatus in
uniffi_merino_fn_method_curatedrecommendationsclient_get_curated_recommendations(
self.uniffiCloneHandle(),
FfiConverterTypeCuratedRecommendationsRequest_lower(request),uniffiCallStatus
)
})
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCuratedRecommendationsClient: FfiConverter {
typealias FfiType = UInt64
typealias SwiftType = CuratedRecommendationsClient
public static func lift(_ handle: UInt64) throws -> CuratedRecommendationsClient {
return CuratedRecommendationsClient(unsafeFromHandle: handle)
}
public static func lower(_ value: CuratedRecommendationsClient) -> UInt64 {
return value.uniffiCloneHandle()
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CuratedRecommendationsClient {
let handle: UInt64 = try readInt(&buf)
return try lift(handle)
}
public static func write(_ value: CuratedRecommendationsClient, into buf: inout [UInt8]) {
writeInt(&buf, lower(value))
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCuratedRecommendationsClient_lift(_ handle: UInt64) throws -> CuratedRecommendationsClient {
return try FfiConverterTypeCuratedRecommendationsClient.lift(handle)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCuratedRecommendationsClient_lower(_ value: CuratedRecommendationsClient) -> UInt64 {
return FfiConverterTypeCuratedRecommendationsClient.lower(value)
}
/**
* A client for the merino suggest endpoint.
*
* Use [`SuggestClient::new`] to create an instance, then call
* [`SuggestClient::get_suggestions`] to fetch suggestions for a query.
*/
public protocol SuggestClientProtocol: AnyObject, Sendable {
/**
* Fetches suggestions from the merino suggest endpoint for the given query.
*
* Returns the raw JSON response body as a string, or `None` if the server
* returned HTTP 204 (no suggestions available for weather).
*/
func getSuggestions(query: String, options: SuggestOptions) throws -> String?
/**
* Ends the current search session.
*
* A new session, with a new session ID and the sequence number reset to 0,
* is started on the next call to [`SuggestClient::get_suggestions`].
*
* Consumers should call this whenever a search session ends (e.g. the user
* navigates away from the address bar). Consumers may also call it to end a
* long-lived session after a certain duration for better privacy protection.
*/
func resetSession()
}
/**
* A client for the merino suggest endpoint.
*
* Use [`SuggestClient::new`] to create an instance, then call
* [`SuggestClient::get_suggestions`] to fetch suggestions for a query.
*/
open class SuggestClient: SuggestClientProtocol, @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_merino_fn_clone_suggestclient(self.handle, $0) }
}
/**
* Creates a new `SuggestClient` from the given configuration.
*/
public convenience init(config: SuggestConfig)throws {
let handle =
try rustCallWithError(FfiConverterTypeMerinoSuggestApiError_lift) {
uniffiCallStatus in
uniffi_merino_fn_constructor_suggestclient_new(
FfiConverterTypeSuggestConfig_lower(config),uniffiCallStatus
)
}
self.init(unsafeFromHandle: handle)
}
deinit {
if handle == 0 {
// Mock objects have handle=0 don't try to free them
return
}
try! rustCall { uniffi_merino_fn_free_suggestclient(handle, $0) }
}
/**
* Fetches suggestions from the merino suggest endpoint for the given query.
*
* Returns the raw JSON response body as a string, or `None` if the server
* returned HTTP 204 (no suggestions available for weather).
*/
open func getSuggestions(query: String, options: SuggestOptions)throws -> String? {
return try FfiConverterOptionString.lift(try rustCallWithError(FfiConverterTypeMerinoSuggestApiError_lift) {
uniffiCallStatus in
uniffi_merino_fn_method_suggestclient_get_suggestions(
self.uniffiCloneHandle(),
FfiConverterString.lower(query),
FfiConverterTypeSuggestOptions_lower(options),uniffiCallStatus
)
})
}
/**
* Ends the current search session.
*
* A new session, with a new session ID and the sequence number reset to 0,
* is started on the next call to [`SuggestClient::get_suggestions`].
*
* Consumers should call this whenever a search session ends (e.g. the user
* navigates away from the address bar). Consumers may also call it to end a
* long-lived session after a certain duration for better privacy protection.
*/
open func resetSession() {try! rustCall() {
uniffiCallStatus in
uniffi_merino_fn_method_suggestclient_reset_session(
self.uniffiCloneHandle(),uniffiCallStatus
)
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeSuggestClient: FfiConverter {
typealias FfiType = UInt64
typealias SwiftType = SuggestClient
public static func lift(_ handle: UInt64) throws -> SuggestClient {
return SuggestClient(unsafeFromHandle: handle)
}
public static func lower(_ value: SuggestClient) -> UInt64 {
return value.uniffiCloneHandle()
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SuggestClient {
let handle: UInt64 = try readInt(&buf)
return try lift(handle)
}
public static func write(_ value: SuggestClient, into buf: inout [UInt8]) {
writeInt(&buf, lower(value))
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeSuggestClient_lift(_ handle: UInt64) throws -> SuggestClient {
return try FfiConverterTypeSuggestClient.lift(handle)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeSuggestClient_lower(_ value: SuggestClient) -> UInt64 {
return FfiConverterTypeSuggestClient.lower(value)
}
/**
* A client for the merino Wrexham widget endpoints.
*
* Use [`WrexhamClient::new`] to create an instance, then call
* [`WrexhamClient::get_matches`] or [`WrexhamClient::get_standings`].
*/
public protocol WrexhamClientProtocol: AnyObject, Sendable {
/**
* Fetches Wrexham's previous, current and upcoming matches.
*
* Returns the raw JSON response body as a string.
*/
func getMatches(options: WrexhamMatchesOptions) throws -> String
/**
* Fetches the EFL Championship table.
*
* Returns the raw JSON response body as a string.
*/
func getStandings() throws -> String
}
/**
* A client for the merino Wrexham widget endpoints.
*
* Use [`WrexhamClient::new`] to create an instance, then call
* [`WrexhamClient::get_matches`] or [`WrexhamClient::get_standings`].
*/
open class WrexhamClient: WrexhamClientProtocol, @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_merino_fn_clone_wrexhamclient(self.handle, $0) }
}
/**
* Creates a new `WrexhamClient` from the given configuration.
*/
public convenience init(config: WrexhamConfig)throws {
let handle =
try rustCallWithError(FfiConverterTypeMerinoWrexhamApiError_lift) {
uniffiCallStatus in
uniffi_merino_fn_constructor_wrexhamclient_new(
FfiConverterTypeWrexhamConfig_lower(config),uniffiCallStatus
)
}
self.init(unsafeFromHandle: handle)
}
deinit {
if handle == 0 {
// Mock objects have handle=0 don't try to free them
return
}
try! rustCall { uniffi_merino_fn_free_wrexhamclient(handle, $0) }
}
/**
* Fetches Wrexham's previous, current and upcoming matches.
*
* Returns the raw JSON response body as a string.
*/
open func getMatches(options: WrexhamMatchesOptions)throws -> String {
return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeMerinoWrexhamApiError_lift) {
uniffiCallStatus in
uniffi_merino_fn_method_wrexhamclient_get_matches(
self.uniffiCloneHandle(),
FfiConverterTypeWrexhamMatchesOptions_lower(options),uniffiCallStatus
)
})
}
/**
* Fetches the EFL Championship table.
*
* Returns the raw JSON response body as a string.
*/
open func getStandings()throws -> String {
return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeMerinoWrexhamApiError_lift) {
uniffiCallStatus in
uniffi_merino_fn_method_wrexhamclient_get_standings(
self.uniffiCloneHandle(),uniffiCallStatus
)
})
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeWrexhamClient: FfiConverter {
typealias FfiType = UInt64
typealias SwiftType = WrexhamClient
public static func lift(_ handle: UInt64) throws -> WrexhamClient {
return WrexhamClient(unsafeFromHandle: handle)
}
public static func lower(_ value: WrexhamClient) -> UInt64 {
return value.uniffiCloneHandle()
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WrexhamClient {
let handle: UInt64 = try readInt(&buf)
return try lift(handle)
}
public static func write(_ value: WrexhamClient, into buf: inout [UInt8]) {
writeInt(&buf, lower(value))
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeWrexhamClient_lift(_ handle: UInt64) throws -> WrexhamClient {
return try FfiConverterTypeWrexhamClient.lift(handle)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeWrexhamClient_lower(_ value: WrexhamClient) -> UInt64 {
return FfiConverterTypeWrexhamClient.lower(value)
}
/**
* Configuration options for initializing a [`CuratedRecommendationsClient`](crate::curated_recommendations::CuratedRecommendationsClient).
*/
public struct CuratedRecommendationsConfig: Equatable, Hashable, Codable {
/**
* Optional custom base host URL. Defaults to the production Merino service if `None`.
*/
public var baseHost: String?
/**
* The `User-Agent` header value to send with API requests.
*/
public var userAgentHeader: String
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* Optional custom base host URL. Defaults to the production Merino service if `None`.
*/baseHost: String?,
/**
* The `User-Agent` header value to send with API requests.
*/userAgentHeader: String) {
self.baseHost = baseHost
self.userAgentHeader = userAgentHeader
}
}
#if compiler(>=6)
extension CuratedRecommendationsConfig: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCuratedRecommendationsConfig: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CuratedRecommendationsConfig {
return
try CuratedRecommendationsConfig(
baseHost: FfiConverterOptionString.read(from: &buf),
userAgentHeader: FfiConverterString.read(from: &buf)
)
}
public static func write(_ value: CuratedRecommendationsConfig, into buf: inout [UInt8]) {
FfiConverterOptionString.write(value.baseHost, into: &buf)
FfiConverterString.write(value.userAgentHeader, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCuratedRecommendationsConfig_lift(_ buf: RustBuffer) throws -> CuratedRecommendationsConfig {
return try FfiConverterTypeCuratedRecommendationsConfig.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCuratedRecommendationsConfig_lower(_ value: CuratedRecommendationsConfig) -> RustBuffer {
return FfiConverterTypeCuratedRecommendationsConfig.lower(value)
}
/**
* Parameters for requesting curated recommendations from the Merino API.
*/
public struct CuratedRecommendationsRequest: Equatable, Hashable, Codable {
/**
* The locale to use when selecting recommendations.
*/
public var locale: CuratedRecommendationLocale
/**
* Optional ISO 3166-1 region code (e.g. `"US"`, `"GB"`) to further refine results.
*/
public var region: String?
/**
* Maximum number of recommendations to return. Defaults to 100 if not specified.
*/
public var count: Int32?
/**
* Optional list of topic slugs to filter recommendations by (e.g. `"business"`, `"tech"`).
*/
public var topics: [String]?
/**
* Optional list of feed types to include in the response (e.g. `"sections"`).
*/
public var feeds: [String]?
/**
* Optional per-section follow/block preferences.
*/
public var sections: [SectionSettings]?
/**
* Optional experiment name for server-side A/B testing.
*/
public var experimentName: String?
/**
* Optional experiment branch for server-side A/B testing.
*/
public var experimentBranch: String?
/**
* Whether to include the interest picker in the response.
*/
public var enableInterestPicker: Bool
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* The locale to use when selecting recommendations.
*/locale: CuratedRecommendationLocale,
/**
* Optional ISO 3166-1 region code (e.g. `"US"`, `"GB"`) to further refine results.
*/region: String? = nil,
/**
* Maximum number of recommendations to return. Defaults to 100 if not specified.
*/count: Int32? = 100,
/**
* Optional list of topic slugs to filter recommendations by (e.g. `"business"`, `"tech"`).
*/topics: [String]? = nil,
/**
* Optional list of feed types to include in the response (e.g. `"sections"`).
*/feeds: [String]? = nil,
/**
* Optional per-section follow/block preferences.
*/sections: [SectionSettings]? = nil,
/**
* Optional experiment name for server-side A/B testing.
*/experimentName: String? = nil,
/**
* Optional experiment branch for server-side A/B testing.
*/experimentBranch: String? = nil,
/**
* Whether to include the interest picker in the response.
*/enableInterestPicker: Bool = false) {
self.locale = locale
self.region = region
self.count = count
self.topics = topics
self.feeds = feeds
self.sections = sections
self.experimentName = experimentName
self.experimentBranch = experimentBranch
self.enableInterestPicker = enableInterestPicker
}
}
#if compiler(>=6)
extension CuratedRecommendationsRequest: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCuratedRecommendationsRequest: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CuratedRecommendationsRequest {
return
try CuratedRecommendationsRequest(
locale: FfiConverterTypeCuratedRecommendationLocale.read(from: &buf),
region: FfiConverterOptionString.read(from: &buf),
count: FfiConverterOptionInt32.read(from: &buf),
topics: FfiConverterOptionSequenceString.read(from: &buf),
feeds: FfiConverterOptionSequenceString.read(from: &buf),
sections: FfiConverterOptionSequenceTypeSectionSettings.read(from: &buf),
experimentName: FfiConverterOptionString.read(from: &buf),
experimentBranch: FfiConverterOptionString.read(from: &buf),
enableInterestPicker: FfiConverterBool.read(from: &buf)
)
}
public static func write(_ value: CuratedRecommendationsRequest, into buf: inout [UInt8]) {
FfiConverterTypeCuratedRecommendationLocale.write(value.locale, into: &buf)
FfiConverterOptionString.write(value.region, into: &buf)
FfiConverterOptionInt32.write(value.count, into: &buf)
FfiConverterOptionSequenceString.write(value.topics, into: &buf)
FfiConverterOptionSequenceString.write(value.feeds, into: &buf)
FfiConverterOptionSequenceTypeSectionSettings.write(value.sections, into: &buf)
FfiConverterOptionString.write(value.experimentName, into: &buf)
FfiConverterOptionString.write(value.experimentBranch, into: &buf)
FfiConverterBool.write(value.enableInterestPicker, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCuratedRecommendationsRequest_lift(_ buf: RustBuffer) throws -> CuratedRecommendationsRequest {
return try FfiConverterTypeCuratedRecommendationsRequest.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCuratedRecommendationsRequest_lower(_ value: CuratedRecommendationsRequest) -> RustBuffer {
return FfiConverterTypeCuratedRecommendationsRequest.lower(value)
}
/**
* Top-level response from the Merino curated recommendations API.
*/
public struct CuratedRecommendationsResponse: Equatable, Hashable, Codable {
/**
* Timestamp (in milliseconds since epoch) when the recommendations were generated.
*/
public var recommendedAt: Int64
/**
* The list of recommended items.
*/
public var data: [RecommendationDataItem]
/**
* Optional categorized feeds (e.g. by topic section).
*/
public var feeds: [FeedSection]?
/**
* Optional interest picker configuration for displaying section selection UI.
*/
public var interestPicker: InterestPicker?
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* Timestamp (in milliseconds since epoch) when the recommendations were generated.
*/recommendedAt: Int64,
/**
* The list of recommended items.
*/data: [RecommendationDataItem],
/**
* Optional categorized feeds (e.g. by topic section).
*/feeds: [FeedSection]? = nil,
/**
* Optional interest picker configuration for displaying section selection UI.
*/interestPicker: InterestPicker? = nil) {
self.recommendedAt = recommendedAt
self.data = data
self.feeds = feeds
self.interestPicker = interestPicker
}
}
#if compiler(>=6)
extension CuratedRecommendationsResponse: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCuratedRecommendationsResponse: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CuratedRecommendationsResponse {
return
try CuratedRecommendationsResponse(
recommendedAt: FfiConverterInt64.read(from: &buf),
data: FfiConverterSequenceTypeRecommendationDataItem.read(from: &buf),
feeds: FfiConverterOptionSequenceTypeFeedSection.read(from: &buf),
interestPicker: FfiConverterOptionTypeInterestPicker.read(from: &buf)
)
}
public static func write(_ value: CuratedRecommendationsResponse, into buf: inout [UInt8]) {
FfiConverterInt64.write(value.recommendedAt, into: &buf)
FfiConverterSequenceTypeRecommendationDataItem.write(value.data, into: &buf)
FfiConverterOptionSequenceTypeFeedSection.write(value.feeds, into: &buf)
FfiConverterOptionTypeInterestPicker.write(value.interestPicker, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCuratedRecommendationsResponse_lift(_ buf: RustBuffer) throws -> CuratedRecommendationsResponse {
return try FfiConverterTypeCuratedRecommendationsResponse.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCuratedRecommendationsResponse_lower(_ value: CuratedRecommendationsResponse) -> RustBuffer {
return FfiConverterTypeCuratedRecommendationsResponse.lower(value)
}
/**
* A categorized feed section containing recommendations and responsive layout configuration.
*/
public struct FeedSection: Equatable, Hashable, Codable {
/**
* Identifier for this feed section (the key from the API response map,
* e.g. `"top_stories_section"`, `"travel"`, `"arts"`).
*/
public var feedId: String
/**
* The display position of this section within the overall feed.
*/
public var receivedFeedRank: Int32
/**
* The recommendations in this section.
*/
public var recommendations: [RecommendationDataItem]
/**
* Display title for this section.
*/
public var title: String
/**
* Optional subtitle for this section.
*/
public var subtitle: String?
/**
* Responsive layout configuration for rendering this section.
*/
public var layout: Layout
/**
* Whether the user is following this section.
*/
public var isFollowed: Bool
/**
* Whether the user has blocked this section.
*/
public var isBlocked: Bool
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* Identifier for this feed section (the key from the API response map,
* e.g. `"top_stories_section"`, `"travel"`, `"arts"`).
*/feedId: String,
/**
* The display position of this section within the overall feed.
*/receivedFeedRank: Int32,
/**
* The recommendations in this section.
*/recommendations: [RecommendationDataItem],
/**
* Display title for this section.
*/title: String,
/**
* Optional subtitle for this section.
*/subtitle: String? = nil,
/**
* Responsive layout configuration for rendering this section.
*/layout: Layout,
/**
* Whether the user is following this section.
*/isFollowed: Bool,
/**
* Whether the user has blocked this section.
*/isBlocked: Bool) {
self.feedId = feedId
self.receivedFeedRank = receivedFeedRank
self.recommendations = recommendations
self.title = title
self.subtitle = subtitle
self.layout = layout
self.isFollowed = isFollowed
self.isBlocked = isBlocked
}
}
#if compiler(>=6)
extension FeedSection: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeFeedSection: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FeedSection {
return
try FeedSection(
feedId: FfiConverterString.read(from: &buf),
receivedFeedRank: FfiConverterInt32.read(from: &buf),
recommendations: FfiConverterSequenceTypeRecommendationDataItem.read(from: &buf),
title: FfiConverterString.read(from: &buf),
subtitle: FfiConverterOptionString.read(from: &buf),
layout: FfiConverterTypeLayout.read(from: &buf),
isFollowed: FfiConverterBool.read(from: &buf),
isBlocked: FfiConverterBool.read(from: &buf)
)
}
public static func write(_ value: FeedSection, into buf: inout [UInt8]) {
FfiConverterString.write(value.feedId, into: &buf)
FfiConverterInt32.write(value.receivedFeedRank, into: &buf)
FfiConverterSequenceTypeRecommendationDataItem.write(value.recommendations, into: &buf)
FfiConverterString.write(value.title, into: &buf)
FfiConverterOptionString.write(value.subtitle, into: &buf)
FfiConverterTypeLayout.write(value.layout, into: &buf)
FfiConverterBool.write(value.isFollowed, into: &buf)
FfiConverterBool.write(value.isBlocked, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFeedSection_lift(_ buf: RustBuffer) throws -> FeedSection {
return try FfiConverterTypeFeedSection.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFeedSection_lower(_ value: FeedSection) -> RustBuffer {
return FfiConverterTypeFeedSection.lower(value)
}
/**
* Configuration for the interest picker UI, which lets users select preferred content sections.
*/
public struct InterestPicker: Equatable, Hashable, Codable {
/**
* The display position of the interest picker within the feed.
*/
public var receivedFeedRank: Int32
/**
* Title text for the interest picker.
*/
public var title: String
/**
* Subtitle text for the interest picker.
*/
public var subtitle: String
/**
* The sections available for the user to choose from.
*/
public var sections: [InterestPickerSection]
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* The display position of the interest picker within the feed.
*/receivedFeedRank: Int32,
/**
* Title text for the interest picker.
*/title: String,
/**
* Subtitle text for the interest picker.
*/subtitle: String,
/**
* The sections available for the user to choose from.
*/sections: [InterestPickerSection]) {
self.receivedFeedRank = receivedFeedRank
self.title = title
self.subtitle = subtitle
self.sections = sections
}
}
#if compiler(>=6)
extension InterestPicker: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeInterestPicker: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> InterestPicker {
return
try InterestPicker(
receivedFeedRank: FfiConverterInt32.read(from: &buf),
title: FfiConverterString.read(from: &buf),
subtitle: FfiConverterString.read(from: &buf),
sections: FfiConverterSequenceTypeInterestPickerSection.read(from: &buf)
)
}
public static func write(_ value: InterestPicker, into buf: inout [UInt8]) {
FfiConverterInt32.write(value.receivedFeedRank, into: &buf)
FfiConverterString.write(value.title, into: &buf)
FfiConverterString.write(value.subtitle, into: &buf)
FfiConverterSequenceTypeInterestPickerSection.write(value.sections, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeInterestPicker_lift(_ buf: RustBuffer) throws -> InterestPicker {
return try FfiConverterTypeInterestPicker.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeInterestPicker_lower(_ value: InterestPicker) -> RustBuffer {
return FfiConverterTypeInterestPicker.lower(value)
}
/**
* A section entry within the interest picker.
*/
public struct InterestPickerSection: Equatable, Hashable, Codable {
/**
* Unique identifier for the section.
*/
public var sectionId: String
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* Unique identifier for the section.
*/sectionId: String) {
self.sectionId = sectionId
}
}
#if compiler(>=6)
extension InterestPickerSection: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeInterestPickerSection: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> InterestPickerSection {
return
try InterestPickerSection(
sectionId: FfiConverterString.read(from: &buf)
)
}
public static func write(_ value: InterestPickerSection, into buf: inout [UInt8]) {
FfiConverterString.write(value.sectionId, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeInterestPickerSection_lift(_ buf: RustBuffer) throws -> InterestPickerSection {
return try FfiConverterTypeInterestPickerSection.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeInterestPickerSection_lower(_ value: InterestPickerSection) -> RustBuffer {
return FfiConverterTypeInterestPickerSection.lower(value)
}
/**
* A named layout configuration containing one or more responsive layout breakpoints.
*/
public struct Layout: Equatable, Hashable, Codable {
/**
* Name identifier for this layout (e.g. `"4-large"`, `"3-medium"`).
*/
public var name: String
/**
* Responsive layout variants for different screen widths.
*/
public var responsiveLayouts: [ResponsiveLayout]
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* Name identifier for this layout (e.g. `"4-large"`, `"3-medium"`).
*/name: String,
/**
* Responsive layout variants for different screen widths.
*/responsiveLayouts: [ResponsiveLayout]) {
self.name = name
self.responsiveLayouts = responsiveLayouts
}
}
#if compiler(>=6)
extension Layout: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeLayout: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Layout {
return
try Layout(
name: FfiConverterString.read(from: &buf),
responsiveLayouts: FfiConverterSequenceTypeResponsiveLayout.read(from: &buf)
)
}
public static func write(_ value: Layout, into buf: inout [UInt8]) {
FfiConverterString.write(value.name, into: &buf)
FfiConverterSequenceTypeResponsiveLayout.write(value.responsiveLayouts, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeLayout_lift(_ buf: RustBuffer) throws -> Layout {
return try FfiConverterTypeLayout.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeLayout_lower(_ value: Layout) -> RustBuffer {
return FfiConverterTypeLayout.lower(value)
}
/**
* A single curated recommendation item.
*/
public struct RecommendationDataItem: Equatable, Hashable, Codable {
/**
* Unique identifier for the corpus item.
*/
public var corpusItemId: String
/**
* Unique identifier for the scheduled corpus item.
*/
public var scheduledCorpusItemId: String?
/**
* URL of the recommended article.
*/
public var url: String
/**
* Title of the recommended article.
*/
public var title: String
/**
* Short excerpt or summary of the article.
*/
public var excerpt: String
/**
* Optional topic slug (e.g. `"business"`, `"government"`).
*/
public var topic: String?
/**
* Name of the publisher.
*/
public var publisher: String
/**
* Whether the recommendation is time-sensitive (e.g. breaking news).
*/
public var isTimeSensitive: Bool
/**
* URL of the article's hero/thumbnail image.
*/
public var imageUrl: String
/**
* Optional URL of the publisher's favicon.
*/
public var iconUrl: String?
/**
* Numeric tile identifier used for telemetry.
*/
public var tileId: Int64?
/**
* The position rank at which this item was received from the server.
*/
public var receivedRank: Int64
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* Unique identifier for the corpus item.
*/corpusItemId: String,
/**
* Unique identifier for the scheduled corpus item.
*/scheduledCorpusItemId: String? = nil,
/**
* URL of the recommended article.
*/url: String,
/**
* Title of the recommended article.
*/title: String,
/**
* Short excerpt or summary of the article.
*/excerpt: String,
/**
* Optional topic slug (e.g. `"business"`, `"government"`).
*/topic: String? = nil,
/**
* Name of the publisher.
*/publisher: String,
/**
* Whether the recommendation is time-sensitive (e.g. breaking news).
*/isTimeSensitive: Bool,
/**
* URL of the article's hero/thumbnail image.
*/imageUrl: String,
/**
* Optional URL of the publisher's favicon.
*/iconUrl: String?,
/**
* Numeric tile identifier used for telemetry.
*/tileId: Int64? = nil,
/**
* The position rank at which this item was received from the server.
*/receivedRank: Int64) {
self.corpusItemId = corpusItemId
self.scheduledCorpusItemId = scheduledCorpusItemId
self.url = url
self.title = title
self.excerpt = excerpt
self.topic = topic
self.publisher = publisher
self.isTimeSensitive = isTimeSensitive
self.imageUrl = imageUrl
self.iconUrl = iconUrl
self.tileId = tileId
self.receivedRank = receivedRank
}
}
#if compiler(>=6)
extension RecommendationDataItem: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeRecommendationDataItem: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RecommendationDataItem {
return
try RecommendationDataItem(
corpusItemId: FfiConverterString.read(from: &buf),
scheduledCorpusItemId: FfiConverterOptionString.read(from: &buf),
url: FfiConverterString.read(from: &buf),
title: FfiConverterString.read(from: &buf),
excerpt: FfiConverterString.read(from: &buf),
topic: FfiConverterOptionString.read(from: &buf),
publisher: FfiConverterString.read(from: &buf),
isTimeSensitive: FfiConverterBool.read(from: &buf),
imageUrl: FfiConverterString.read(from: &buf),
iconUrl: FfiConverterOptionString.read(from: &buf),
tileId: FfiConverterOptionInt64.read(from: &buf),
receivedRank: FfiConverterInt64.read(from: &buf)
)
}
public static func write(_ value: RecommendationDataItem, into buf: inout [UInt8]) {
FfiConverterString.write(value.corpusItemId, into: &buf)
FfiConverterOptionString.write(value.scheduledCorpusItemId, into: &buf)
FfiConverterString.write(value.url, into: &buf)
FfiConverterString.write(value.title, into: &buf)
FfiConverterString.write(value.excerpt, into: &buf)
FfiConverterOptionString.write(value.topic, into: &buf)
FfiConverterString.write(value.publisher, into: &buf)
FfiConverterBool.write(value.isTimeSensitive, into: &buf)
FfiConverterString.write(value.imageUrl, into: &buf)
FfiConverterOptionString.write(value.iconUrl, into: &buf)
FfiConverterOptionInt64.write(value.tileId, into: &buf)
FfiConverterInt64.write(value.receivedRank, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRecommendationDataItem_lift(_ buf: RustBuffer) throws -> RecommendationDataItem {
return try FfiConverterTypeRecommendationDataItem.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRecommendationDataItem_lower(_ value: RecommendationDataItem) -> RustBuffer {
return FfiConverterTypeRecommendationDataItem.lower(value)
}
/**
* A layout variant for a specific column count, defining how tiles are arranged.
*/
public struct ResponsiveLayout: Equatable, Hashable, Codable {
/**
* Number of columns in this layout variant.
*/
public var columnCount: Int32
/**
* Tile configurations for this layout.
*/
public var tiles: [Tile]
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* Number of columns in this layout variant.
*/columnCount: Int32,
/**
* Tile configurations for this layout.
*/tiles: [Tile]) {
self.columnCount = columnCount
self.tiles = tiles
}
}
#if compiler(>=6)
extension ResponsiveLayout: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeResponsiveLayout: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ResponsiveLayout {
return
try ResponsiveLayout(
columnCount: FfiConverterInt32.read(from: &buf),
tiles: FfiConverterSequenceTypeTile.read(from: &buf)
)
}
public static func write(_ value: ResponsiveLayout, into buf: inout [UInt8]) {
FfiConverterInt32.write(value.columnCount, into: &buf)
FfiConverterSequenceTypeTile.write(value.tiles, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeResponsiveLayout_lift(_ buf: RustBuffer) throws -> ResponsiveLayout {
return try FfiConverterTypeResponsiveLayout.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeResponsiveLayout_lower(_ value: ResponsiveLayout) -> RustBuffer {
return FfiConverterTypeResponsiveLayout.lower(value)
}
/**
* User preferences for a content section, controlling whether it is followed or blocked.
*/
public struct SectionSettings: Equatable, Hashable, Codable {
/**
* Unique identifier for the section.
*/
public var sectionId: String
/**
* Whether the user has opted to follow this section.
*/
public var isFollowed: Bool
/**
* Whether the user has opted to block this section.
*/
public var isBlocked: Bool
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* Unique identifier for the section.
*/sectionId: String,
/**
* Whether the user has opted to follow this section.
*/isFollowed: Bool,
/**
* Whether the user has opted to block this section.
*/isBlocked: Bool) {
self.sectionId = sectionId
self.isFollowed = isFollowed
self.isBlocked = isBlocked
}
}
#if compiler(>=6)
extension SectionSettings: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeSectionSettings: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SectionSettings {
return
try SectionSettings(
sectionId: FfiConverterString.read(from: &buf),
isFollowed: FfiConverterBool.read(from: &buf),
isBlocked: FfiConverterBool.read(from: &buf)
)
}
public static func write(_ value: SectionSettings, into buf: inout [UInt8]) {
FfiConverterString.write(value.sectionId, into: &buf)
FfiConverterBool.write(value.isFollowed, into: &buf)
FfiConverterBool.write(value.isBlocked, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeSectionSettings_lift(_ buf: RustBuffer) throws -> SectionSettings {
return try FfiConverterTypeSectionSettings.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeSectionSettings_lower(_ value: SectionSettings) -> RustBuffer {
return FfiConverterTypeSectionSettings.lower(value)
}
/**
* Configuration for the merino suggest client.
*/
public struct SuggestConfig: Equatable, Hashable, Codable {
/**
* The base host for the merino endpoint. Defaults to the production host if not set.
*/
public var baseHost: String?
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* The base host for the merino endpoint. Defaults to the production host if not set.
*/baseHost: String?) {
self.baseHost = baseHost
}
}
#if compiler(>=6)
extension SuggestConfig: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeSuggestConfig: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SuggestConfig {
return
try SuggestConfig(
baseHost: FfiConverterOptionString.read(from: &buf)
)
}
public static func write(_ value: SuggestConfig, into buf: inout [UInt8]) {
FfiConverterOptionString.write(value.baseHost, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeSuggestConfig_lift(_ buf: RustBuffer) throws -> SuggestConfig {
return try FfiConverterTypeSuggestConfig.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeSuggestConfig_lower(_ value: SuggestConfig) -> RustBuffer {
return FfiConverterTypeSuggestConfig.lower(value)
}
/**
* Options for a suggest request, mapped to merino suggest endpoint query parameters.
* All fields are optional — omitted fields are not sent to merino.
*/
public struct SuggestOptions: Equatable, Hashable, Codable {
/**
* List of suggestion providers to query (e.g. `["wikipedia", "adm"]`).
*/
public var providers: [String]?
/**
* Identifier of which part of firefox the request comes from (e.g. `"urlbar"`, `"newtab"`).
*/
public var source: String?
/**
* ISO 3166-1 country code (e.g. `"US"`).
*/
public var country: String?
/**
* Comma separated string of subdivision code(s) (e.g. `"CA"`).
*/
public var region: String?
/**
* City name (e.g. `"San Francisco"`).
*/
public var city: String?
/**
* List of any experiments or rollouts that are affecting the client's Suggest experience.
* If Merino recognizes any of them it will modify its behavior accordingly.
*/
public var clientVariants: [String]?
/**
* For AccuWeather provider, the request type should be either a "location" or "weather" string. For "location" it will get location completion suggestion. For "weather" it will return weather suggestions.
* If omitted, it defaults to weather suggestions.
*/
public var requestType: String?
/**
* The `Accept-Language` header value to forward to Merino (e.g. `"en-US"`).
*/
public var acceptLanguage: String?
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* List of suggestion providers to query (e.g. `["wikipedia", "adm"]`).
*/providers: [String]?,
/**
* Identifier of which part of firefox the request comes from (e.g. `"urlbar"`, `"newtab"`).
*/source: String?,
/**
* ISO 3166-1 country code (e.g. `"US"`).
*/country: String?,
/**
* Comma separated string of subdivision code(s) (e.g. `"CA"`).
*/region: String?,
/**
* City name (e.g. `"San Francisco"`).
*/city: String?,
/**
* List of any experiments or rollouts that are affecting the client's Suggest experience.
* If Merino recognizes any of them it will modify its behavior accordingly.
*/clientVariants: [String]?,
/**
* For AccuWeather provider, the request type should be either a "location" or "weather" string. For "location" it will get location completion suggestion. For "weather" it will return weather suggestions.
* If omitted, it defaults to weather suggestions.
*/requestType: String?,
/**
* The `Accept-Language` header value to forward to Merino (e.g. `"en-US"`).
*/acceptLanguage: String?) {
self.providers = providers
self.source = source
self.country = country
self.region = region
self.city = city
self.clientVariants = clientVariants
self.requestType = requestType
self.acceptLanguage = acceptLanguage
}
}
#if compiler(>=6)
extension SuggestOptions: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeSuggestOptions: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SuggestOptions {
return
try SuggestOptions(
providers: FfiConverterOptionSequenceString.read(from: &buf),
source: FfiConverterOptionString.read(from: &buf),
country: FfiConverterOptionString.read(from: &buf),
region: FfiConverterOptionString.read(from: &buf),
city: FfiConverterOptionString.read(from: &buf),
clientVariants: FfiConverterOptionSequenceString.read(from: &buf),
requestType: FfiConverterOptionString.read(from: &buf),
acceptLanguage: FfiConverterOptionString.read(from: &buf)
)
}
public static func write(_ value: SuggestOptions, into buf: inout [UInt8]) {
FfiConverterOptionSequenceString.write(value.providers, into: &buf)
FfiConverterOptionString.write(value.source, into: &buf)
FfiConverterOptionString.write(value.country, into: &buf)
FfiConverterOptionString.write(value.region, into: &buf)
FfiConverterOptionString.write(value.city, into: &buf)
FfiConverterOptionSequenceString.write(value.clientVariants, into: &buf)
FfiConverterOptionString.write(value.requestType, into: &buf)
FfiConverterOptionString.write(value.acceptLanguage, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeSuggestOptions_lift(_ buf: RustBuffer) throws -> SuggestOptions {
return try FfiConverterTypeSuggestOptions.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeSuggestOptions_lower(_ value: SuggestOptions) -> RustBuffer {
return FfiConverterTypeSuggestOptions.lower(value)
}
/**
* Properties for a single tile within a responsive layout.
*/
public struct Tile: Equatable, Hashable, Codable {
/**
* Display size of the tile (e.g. `"large"`, `"medium"`, `"small"`).
*/
public var size: String
/**
* Zero-based position index of this tile within the layout.
*/
public var position: Int32
/**
* Whether this tile position may contain an advertisement.
*/
public var hasAd: Bool
/**
* Whether this tile should display an article excerpt.
*/
public var hasExcerpt: Bool
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* Display size of the tile (e.g. `"large"`, `"medium"`, `"small"`).
*/size: String,
/**
* Zero-based position index of this tile within the layout.
*/position: Int32,
/**
* Whether this tile position may contain an advertisement.
*/hasAd: Bool,
/**
* Whether this tile should display an article excerpt.
*/hasExcerpt: Bool) {
self.size = size
self.position = position
self.hasAd = hasAd
self.hasExcerpt = hasExcerpt
}
}
#if compiler(>=6)
extension Tile: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeTile: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Tile {
return
try Tile(
size: FfiConverterString.read(from: &buf),
position: FfiConverterInt32.read(from: &buf),
hasAd: FfiConverterBool.read(from: &buf),
hasExcerpt: FfiConverterBool.read(from: &buf)
)
}
public static func write(_ value: Tile, into buf: inout [UInt8]) {
FfiConverterString.write(value.size, into: &buf)
FfiConverterInt32.write(value.position, into: &buf)
FfiConverterBool.write(value.hasAd, into: &buf)
FfiConverterBool.write(value.hasExcerpt, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeTile_lift(_ buf: RustBuffer) throws -> Tile {
return try FfiConverterTypeTile.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeTile_lower(_ value: Tile) -> RustBuffer {
return FfiConverterTypeTile.lower(value)
}
/**
* Configuration for the Wrexham widget client.
*/
public struct WrexhamConfig: Equatable, Hashable, Codable {
/**
* The base host for the merino endpoints. Defaults to the production host if not set.
*/
public var baseHost: String?
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* The base host for the merino endpoints. Defaults to the production host if not set.
*/baseHost: String?) {
self.baseHost = baseHost
}
}
#if compiler(>=6)
extension WrexhamConfig: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeWrexhamConfig: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WrexhamConfig {
return
try WrexhamConfig(
baseHost: FfiConverterOptionString.read(from: &buf)
)
}
public static func write(_ value: WrexhamConfig, into buf: inout [UInt8]) {
FfiConverterOptionString.write(value.baseHost, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeWrexhamConfig_lift(_ buf: RustBuffer) throws -> WrexhamConfig {
return try FfiConverterTypeWrexhamConfig.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeWrexhamConfig_lower(_ value: WrexhamConfig) -> RustBuffer {
return FfiConverterTypeWrexhamConfig.lower(value)
}
/**
* Options for a matches request. Omitted fields are not sent to merino.
*/
public struct WrexhamMatchesOptions: Equatable, Hashable, Codable {
/**
* The maximum number of previous and upcoming matches to return. Merino decides which
* values are allowed and the default when it isn't set, and returns a `400` for a value it
* aren't limited.
*/
public var limit: UInt32?
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(
/**
* The maximum number of previous and upcoming matches to return. Merino decides which
* values are allowed and the default when it isn't set, and returns a `400` for a value it
* aren't limited.
*/limit: UInt32?) {
self.limit = limit
}
}
#if compiler(>=6)
extension WrexhamMatchesOptions: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeWrexhamMatchesOptions: FfiConverterRustBuffer {
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WrexhamMatchesOptions {
return
try WrexhamMatchesOptions(
limit: FfiConverterOptionUInt32.read(from: &buf)
)
}
public static func write(_ value: WrexhamMatchesOptions, into buf: inout [UInt8]) {
FfiConverterOptionUInt32.write(value.limit, into: &buf)
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeWrexhamMatchesOptions_lift(_ buf: RustBuffer) throws -> WrexhamMatchesOptions {
return try FfiConverterTypeWrexhamMatchesOptions.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeWrexhamMatchesOptions_lower(_ value: WrexhamMatchesOptions) -> RustBuffer {
return FfiConverterTypeWrexhamMatchesOptions.lower(value)
}
/**
* Locales supported by Merino curated recommendations.
*
* Each variant maps to a BCP 47 locale string (e.g. `"en-US"`, `"fr"`) used when
* requesting recommendations from the Merino API.
*/
public enum CuratedRecommendationLocale: Equatable, Hashable, Codable {
case fr
case frFr
case es
case esEs
case it
case itIt
case en
case enCa
case enGb
case enIe
case enUs
case de
case deDe
case deAt
case deCh
case pl
case plPl
}
#if compiler(>=6)
extension CuratedRecommendationLocale: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCuratedRecommendationLocale: FfiConverterRustBuffer {
typealias SwiftType = CuratedRecommendationLocale
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CuratedRecommendationLocale {
let variant: Int32 = try readInt(&buf)
switch variant {
case 1: return .fr
case 2: return .frFr
case 3: return .es
case 4: return .esEs
case 5: return .it
case 6: return .itIt
case 7: return .en
case 8: return .enCa
case 9: return .enGb
case 10: return .enIe
case 11: return .enUs
case 12: return .de
case 13: return .deDe
case 14: return .deAt
case 15: return .deCh
case 16: return .pl
case 17: return .plPl
default: throw UniffiInternalError.unexpectedEnumCase
}
}
public static func write(_ value: CuratedRecommendationLocale, into buf: inout [UInt8]) {
switch value {
case .fr:
writeInt(&buf, Int32(1))
case .frFr:
writeInt(&buf, Int32(2))
case .es:
writeInt(&buf, Int32(3))
case .esEs:
writeInt(&buf, Int32(4))
case .it:
writeInt(&buf, Int32(5))
case .itIt:
writeInt(&buf, Int32(6))
case .en:
writeInt(&buf, Int32(7))
case .enCa:
writeInt(&buf, Int32(8))
case .enGb:
writeInt(&buf, Int32(9))
case .enIe:
writeInt(&buf, Int32(10))
case .enUs:
writeInt(&buf, Int32(11))
case .de:
writeInt(&buf, Int32(12))
case .deDe:
writeInt(&buf, Int32(13))
case .deAt:
writeInt(&buf, Int32(14))
case .deCh:
writeInt(&buf, Int32(15))
case .pl:
writeInt(&buf, Int32(16))
case .plPl:
writeInt(&buf, Int32(17))
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCuratedRecommendationLocale_lift(_ buf: RustBuffer) throws -> CuratedRecommendationLocale {
return try FfiConverterTypeCuratedRecommendationLocale.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCuratedRecommendationLocale_lower(_ value: CuratedRecommendationLocale) -> RustBuffer {
return FfiConverterTypeCuratedRecommendationLocale.lower(value)
}
/**
* Public error type exposed to consumers via UniFFI.
*
* This is a simplified version of [`Error`] suitable for cross-platform callers,
* distinguishing network failures from other errors.
*/
public
enum CuratedRecommendationsApiError: Swift.Error, Equatable, Hashable, Codable, Foundation.LocalizedError {
/**
* A network-level failure (e.g. DNS resolution, connection timeout).
*/
case Network(reason: String
)
/**
* Any other error, including HTTP errors and deserialization failures.
*/
case Other(code: UInt16?, reason: String
)
public var errorDescription: String? {
String(reflecting: self)
}
}
#if compiler(>=6)
extension CuratedRecommendationsApiError: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCuratedRecommendationsApiError: FfiConverterRustBuffer {
typealias SwiftType = CuratedRecommendationsApiError
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CuratedRecommendationsApiError {
let variant: Int32 = try readInt(&buf)
switch variant {
case 1: return .Network(
reason: try FfiConverterString.read(from: &buf)
)
case 2: return .Other(
code: try FfiConverterOptionUInt16.read(from: &buf),
reason: try FfiConverterString.read(from: &buf)
)
default: throw UniffiInternalError.unexpectedEnumCase
}
}
public static func write(_ value: CuratedRecommendationsApiError, into buf: inout [UInt8]) {
switch value {
case let .Network(reason):
writeInt(&buf, Int32(1))
FfiConverterString.write(reason, into: &buf)
case let .Other(code,reason):
writeInt(&buf, Int32(2))
FfiConverterOptionUInt16.write(code, into: &buf)
FfiConverterString.write(reason, into: &buf)
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCuratedRecommendationsApiError_lift(_ buf: RustBuffer) throws -> CuratedRecommendationsApiError {
return try FfiConverterTypeCuratedRecommendationsApiError.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCuratedRecommendationsApiError_lower(_ value: CuratedRecommendationsApiError) -> RustBuffer {
return FfiConverterTypeCuratedRecommendationsApiError.lower(value)
}
public
enum MerinoSuggestApiError: Swift.Error, Equatable, Hashable, Codable, Foundation.LocalizedError {
/**
* A network-level failure.
*/
case Network(reason: String
)
/**
* Any other error, e.g. HTTP errors, validation errors.
*/
case Other(code: UInt16?, reason: String
)
public var errorDescription: String? {
String(reflecting: self)
}
}
#if compiler(>=6)
extension MerinoSuggestApiError: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeMerinoSuggestApiError: FfiConverterRustBuffer {
typealias SwiftType = MerinoSuggestApiError
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MerinoSuggestApiError {
let variant: Int32 = try readInt(&buf)
switch variant {
case 1: return .Network(
reason: try FfiConverterString.read(from: &buf)
)
case 2: return .Other(
code: try FfiConverterOptionUInt16.read(from: &buf),
reason: try FfiConverterString.read(from: &buf)
)
default: throw UniffiInternalError.unexpectedEnumCase
}
}
public static func write(_ value: MerinoSuggestApiError, into buf: inout [UInt8]) {
switch value {
case let .Network(reason):
writeInt(&buf, Int32(1))
FfiConverterString.write(reason, into: &buf)
case let .Other(code,reason):
writeInt(&buf, Int32(2))
FfiConverterOptionUInt16.write(code, into: &buf)
FfiConverterString.write(reason, into: &buf)
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeMerinoSuggestApiError_lift(_ buf: RustBuffer) throws -> MerinoSuggestApiError {
return try FfiConverterTypeMerinoSuggestApiError.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeMerinoSuggestApiError_lower(_ value: MerinoSuggestApiError) -> RustBuffer {
return FfiConverterTypeMerinoSuggestApiError.lower(value)
}
public
enum MerinoWrexhamApiError: Swift.Error, Equatable, Hashable, Codable, Foundation.LocalizedError {
/**
* A network-level failure.
*/
case Network(reason: String
)
/**
* Merino has no Wrexham data it can serve right now (HTTP 503). Try again later.
*/
case Unavailable(reason: String
)
/**
* Any other error, e.g. HTTP errors.
*/
case Other(code: UInt16?, reason: String
)
public var errorDescription: String? {
String(reflecting: self)
}
}
#if compiler(>=6)
extension MerinoWrexhamApiError: Sendable {}
#endif
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeMerinoWrexhamApiError: FfiConverterRustBuffer {
typealias SwiftType = MerinoWrexhamApiError
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MerinoWrexhamApiError {
let variant: Int32 = try readInt(&buf)
switch variant {
case 1: return .Network(
reason: try FfiConverterString.read(from: &buf)
)
case 2: return .Unavailable(
reason: try FfiConverterString.read(from: &buf)
)
case 3: return .Other(
code: try FfiConverterOptionUInt16.read(from: &buf),
reason: try FfiConverterString.read(from: &buf)
)
default: throw UniffiInternalError.unexpectedEnumCase
}
}
public static func write(_ value: MerinoWrexhamApiError, into buf: inout [UInt8]) {
switch value {
case let .Network(reason):
writeInt(&buf, Int32(1))
FfiConverterString.write(reason, into: &buf)
case let .Unavailable(reason):
writeInt(&buf, Int32(2))
FfiConverterString.write(reason, into: &buf)
case let .Other(code,reason):
writeInt(&buf, Int32(3))
FfiConverterOptionUInt16.write(code, into: &buf)
FfiConverterString.write(reason, into: &buf)
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeMerinoWrexhamApiError_lift(_ buf: RustBuffer) throws -> MerinoWrexhamApiError {
return try FfiConverterTypeMerinoWrexhamApiError.lift(buf)
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeMerinoWrexhamApiError_lower(_ value: MerinoWrexhamApiError) -> RustBuffer {
return FfiConverterTypeMerinoWrexhamApiError.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 FfiConverterOptionUInt32: FfiConverterRustBuffer {
typealias SwiftType = UInt32?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterUInt32.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 FfiConverterUInt32.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 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 FfiConverterOptionTypeInterestPicker: FfiConverterRustBuffer {
typealias SwiftType = InterestPicker?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterTypeInterestPicker.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 FfiConverterTypeInterestPicker.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypeCuratedRecommendationLocale: FfiConverterRustBuffer {
typealias SwiftType = CuratedRecommendationLocale?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterTypeCuratedRecommendationLocale.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 FfiConverterTypeCuratedRecommendationLocale.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionSequenceString: 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))
FfiConverterSequenceString.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 FfiConverterSequenceString.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionSequenceTypeFeedSection: FfiConverterRustBuffer {
typealias SwiftType = [FeedSection]?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterSequenceTypeFeedSection.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 FfiConverterSequenceTypeFeedSection.read(from: &buf)
default: throw UniffiInternalError.unexpectedOptionalTag
}
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionSequenceTypeSectionSettings: FfiConverterRustBuffer {
typealias SwiftType = [SectionSettings]?
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
guard let value = value else {
writeInt(&buf, Int8(0))
return
}
writeInt(&buf, Int8(1))
FfiConverterSequenceTypeSectionSettings.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 FfiConverterSequenceTypeSectionSettings.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 FfiConverterSequenceTypeFeedSection: FfiConverterRustBuffer {
typealias SwiftType = [FeedSection]
public static func write(_ value: [FeedSection], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeFeedSection.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [FeedSection] {
let len: Int32 = try readInt(&buf)
var seq = [FeedSection]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeFeedSection.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeInterestPickerSection: FfiConverterRustBuffer {
typealias SwiftType = [InterestPickerSection]
public static func write(_ value: [InterestPickerSection], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeInterestPickerSection.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [InterestPickerSection] {
let len: Int32 = try readInt(&buf)
var seq = [InterestPickerSection]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeInterestPickerSection.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeRecommendationDataItem: FfiConverterRustBuffer {
typealias SwiftType = [RecommendationDataItem]
public static func write(_ value: [RecommendationDataItem], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeRecommendationDataItem.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [RecommendationDataItem] {
let len: Int32 = try readInt(&buf)
var seq = [RecommendationDataItem]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeRecommendationDataItem.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeResponsiveLayout: FfiConverterRustBuffer {
typealias SwiftType = [ResponsiveLayout]
public static func write(_ value: [ResponsiveLayout], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeResponsiveLayout.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ResponsiveLayout] {
let len: Int32 = try readInt(&buf)
var seq = [ResponsiveLayout]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeResponsiveLayout.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeSectionSettings: FfiConverterRustBuffer {
typealias SwiftType = [SectionSettings]
public static func write(_ value: [SectionSettings], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeSectionSettings.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [SectionSettings] {
let len: Int32 = try readInt(&buf)
var seq = [SectionSettings]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeSectionSettings.read(from: &buf))
}
return seq
}
}
#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeTile: FfiConverterRustBuffer {
typealias SwiftType = [Tile]
public static func write(_ value: [Tile], into buf: inout [UInt8]) {
let len = Int32(value.count)
writeInt(&buf, len)
for item in value {
FfiConverterTypeTile.write(item, into: &buf)
}
}
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Tile] {
let len: Int32 = try readInt(&buf)
var seq = [Tile]()
seq.reserveCapacity(Int(len))
for _ in 0 ..< len {
seq.append(try FfiConverterTypeTile.read(from: &buf))
}
return seq
}
}
/**
* Returns a list of all supported locale strings that map to `CuratedRecommendationLocale` variants.
*/
public func allCuratedRecommendationLocales() -> [String] {
return try! FfiConverterSequenceString.lift(try! rustCall() {
uniffiCallStatus in
uniffi_merino_fn_func_all_curated_recommendation_locales(uniffiCallStatus
)
})
}
/**
* Parses a serialized locale string (e.g. `"en-US"`) into a `CuratedRecommendationLocale` enum variant.
*
*
* Returns `None` if the string does not match any known locale.
*/
public func curatedRecommendationLocaleFromString(locale: String) -> CuratedRecommendationLocale? {
return try! FfiConverterOptionTypeCuratedRecommendationLocale.lift(try! rustCall() {
uniffiCallStatus in
uniffi_merino_fn_func_curated_recommendation_locale_from_string(
FfiConverterString.lower(locale),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_merino_uniffi_contract_version()
if bindings_contract_version != scaffolding_contract_version {
return InitializationResult.contractVersionMismatch
}
if (uniffi_merino_checksum_func_all_curated_recommendation_locales() != 59871) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_merino_checksum_func_curated_recommendation_locale_from_string() != 20505) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_merino_checksum_method_curatedrecommendationsclient_get_curated_recommendations() != 28993) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_merino_checksum_method_suggestclient_get_suggestions() != 56465) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_merino_checksum_method_suggestclient_reset_session() != 54784) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_merino_checksum_method_wrexhamclient_get_matches() != 50751) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_merino_checksum_method_wrexhamclient_get_standings() != 22586) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_merino_checksum_constructor_curatedrecommendationsclient_new() != 60403) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_merino_checksum_constructor_suggestclient_new() != 44805) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_merino_checksum_constructor_wrexhamclient_new() != 19775) {
return InitializationResult.apiChecksumMismatch
}
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 uniffiEnsureMerinoInitialized() {
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