8614 lines
257 KiB
Swift
8614 lines
257 KiB
Swift
|
|
// 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(MobileAPIFFI)
|
|||
|
|
import MobileAPIFFI
|
|||
|
|
#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_mobile_api_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_mobile_api_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 {
|
|||
|
|
uniffiEnsureMobileApiInitialized()
|
|||
|
|
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 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 FfiConverterUInt64: FfiConverterPrimitive {
|
|||
|
|
typealias FfiType = UInt64
|
|||
|
|
typealias SwiftType = UInt64
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 {
|
|||
|
|
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 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 FfiConverterFloat: FfiConverterPrimitive {
|
|||
|
|
typealias FfiType = Float
|
|||
|
|
typealias SwiftType = Float
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Float {
|
|||
|
|
return try lift(readFloat(&buf))
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: Float, into buf: inout [UInt8]) {
|
|||
|
|
writeFloat(&buf, lower(value))
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterDouble: FfiConverterPrimitive {
|
|||
|
|
typealias FfiType = Double
|
|||
|
|
typealias SwiftType = Double
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Double {
|
|||
|
|
return try lift(readDouble(&buf))
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: Double, into buf: inout [UInt8]) {
|
|||
|
|
writeDouble(&buf, lower(value))
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterBool : FfiConverter {
|
|||
|
|
typealias FfiType = Int8
|
|||
|
|
typealias SwiftType = Bool
|
|||
|
|
|
|||
|
|
public static func lift(_ value: Int8) throws -> Bool {
|
|||
|
|
return value != 0
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func lower(_ value: Bool) -> Int8 {
|
|||
|
|
return value ? 1 : 0
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Bool {
|
|||
|
|
return try lift(readInt(&buf))
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: Bool, into buf: inout [UInt8]) {
|
|||
|
|
writeInt(&buf, lower(value))
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterString: FfiConverter {
|
|||
|
|
typealias SwiftType = String
|
|||
|
|
typealias FfiType = RustBuffer
|
|||
|
|
|
|||
|
|
public static func lift(_ value: RustBuffer) throws -> String {
|
|||
|
|
defer {
|
|||
|
|
value.deallocate()
|
|||
|
|
}
|
|||
|
|
if value.data == nil {
|
|||
|
|
return String()
|
|||
|
|
}
|
|||
|
|
let bytes = UnsafeBufferPointer<UInt8>(start: value.data!, count: Int(value.len))
|
|||
|
|
// Use Swift's native UTF-8 decoder; `String(bytes:encoding:.utf8)` goes
|
|||
|
|
// through Foundation's NSString and silently strips a leading U+FEFF BOM.
|
|||
|
|
// Invalid UTF-8 substitutes U+FFFD instead of trapping (unreachable
|
|||
|
|
// given Rust's `String` invariant).
|
|||
|
|
return String(decoding: bytes, as: UTF8.self)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func lower(_ value: String) -> RustBuffer {
|
|||
|
|
return value.utf8CString.withUnsafeBufferPointer { ptr in
|
|||
|
|
// The swift string gives us int8_t, we want uint8_t.
|
|||
|
|
ptr.withMemoryRebound(to: UInt8.self) { ptr in
|
|||
|
|
// The swift string gives us a trailing null byte, we don't want it.
|
|||
|
|
let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1))
|
|||
|
|
return RustBuffer.from(buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
// See `lift` above for why we avoid Foundation's NSString-backed decoder here.
|
|||
|
|
return String(decoding: try readBytes(&buf, count: Int(len)), as: UTF8.self)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: String, into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.utf8.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
writeBytes(&buf, value.utf8)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterData: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = Data
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Data {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
return Data(try readBytes(&buf, count: Int(len)))
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: Data, into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
writeBytes(&buf, value)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A running engine.
|
|||
|
|
*/
|
|||
|
|
public protocol AnalyzerProtocol: AnyObject, Sendable {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Analyses the position reached from `start_fen` by `moves` (UCI), with `lines`
|
|||
|
|
* lines, until [`Analyzer::stop`] or the next call. Returns the search's number:
|
|||
|
|
* only snapshots with it belong to this position.
|
|||
|
|
*/
|
|||
|
|
func analyze(startFen: String, moves: [String], lines: UInt32) throws -> UInt64
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Waits up to `timeout_ms` for the engine; returns the analysis of the current
|
|||
|
|
* search when it has changed, `None` otherwise. Fails once the engine has stopped.
|
|||
|
|
*/
|
|||
|
|
func poll(timeoutMs: UInt32) throws -> Analysis?
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Quits the engine (and kills it if it does not leave in time).
|
|||
|
|
*/
|
|||
|
|
func quit()
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Stops the search (its last lines stay valid for its position).
|
|||
|
|
*/
|
|||
|
|
func stop()
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* A running engine.
|
|||
|
|
*/
|
|||
|
|
open class Analyzer: AnalyzerProtocol, @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_mobile_api_fn_clone_analyzer(self.handle, $0) }
|
|||
|
|
}
|
|||
|
|
// No primary constructor declared for this class.
|
|||
|
|
|
|||
|
|
deinit {
|
|||
|
|
if handle == 0 {
|
|||
|
|
// Mock objects have handle=0 don't try to free them
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try! rustCall { uniffi_mobile_api_fn_free_analyzer(handle, $0) }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Starts the engine at `path` with its network `eval_file`. Blocks for the
|
|||
|
|
* handshake (seconds at most): call it off the main thread.
|
|||
|
|
*/
|
|||
|
|
public static func start(path: String, evalFile: String, threads: UInt32, hashMb: UInt32)throws -> Analyzer {
|
|||
|
|
return try FfiConverterTypeAnalyzer_lift(try rustCallWithError(FfiConverterTypeEngineFailure_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_constructor_analyzer_start(
|
|||
|
|
FfiConverterString.lower(path),
|
|||
|
|
FfiConverterString.lower(evalFile),
|
|||
|
|
FfiConverterUInt32.lower(threads),
|
|||
|
|
FfiConverterUInt32.lower(hashMb),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Analyses the position reached from `start_fen` by `moves` (UCI), with `lines`
|
|||
|
|
* lines, until [`Analyzer::stop`] or the next call. Returns the search's number:
|
|||
|
|
* only snapshots with it belong to this position.
|
|||
|
|
*/
|
|||
|
|
open func analyze(startFen: String, moves: [String], lines: UInt32)throws -> UInt64 {
|
|||
|
|
return try FfiConverterUInt64.lift(try rustCallWithError(FfiConverterTypeEngineFailure_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_analyzer_analyze(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterString.lower(startFen),
|
|||
|
|
FfiConverterSequenceString.lower(moves),
|
|||
|
|
FfiConverterUInt32.lower(lines),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Waits up to `timeout_ms` for the engine; returns the analysis of the current
|
|||
|
|
* search when it has changed, `None` otherwise. Fails once the engine has stopped.
|
|||
|
|
*/
|
|||
|
|
open func poll(timeoutMs: UInt32)throws -> Analysis? {
|
|||
|
|
return try FfiConverterOptionTypeAnalysis.lift(try rustCallWithError(FfiConverterTypeEngineFailure_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_analyzer_poll(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(timeoutMs),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Quits the engine (and kills it if it does not leave in time).
|
|||
|
|
*/
|
|||
|
|
open func quit() {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_analyzer_quit(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Stops the search (its last lines stay valid for its position).
|
|||
|
|
*/
|
|||
|
|
open func stop() {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_analyzer_stop(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeAnalyzer: FfiConverter {
|
|||
|
|
typealias FfiType = UInt64
|
|||
|
|
typealias SwiftType = Analyzer
|
|||
|
|
|
|||
|
|
public static func lift(_ handle: UInt64) throws -> Analyzer {
|
|||
|
|
return Analyzer(unsafeFromHandle: handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func lower(_ value: Analyzer) -> UInt64 {
|
|||
|
|
return value.uniffiCloneHandle()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Analyzer {
|
|||
|
|
let handle: UInt64 = try readInt(&buf)
|
|||
|
|
return try lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: Analyzer, into buf: inout [UInt8]) {
|
|||
|
|
writeInt(&buf, lower(value))
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeAnalyzer_lift(_ handle: UInt64) throws -> Analyzer {
|
|||
|
|
return try FfiConverterTypeAnalyzer.lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeAnalyzer_lower(_ value: Analyzer) -> UInt64 {
|
|||
|
|
return FfiConverterTypeAnalyzer.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* An open database.
|
|||
|
|
*/
|
|||
|
|
public protocol DatabaseProtocol: AnyObject, Sendable {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The numbers of the games whose players, event, site, date or opening code (ECO)
|
|||
|
|
* contain every word of `text` (case does not matter); all games for an empty text.
|
|||
|
|
*/
|
|||
|
|
func find(text: String) -> [UInt32]
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* What the database was read from ("PGN", "ChessBase", "zip", …).
|
|||
|
|
*/
|
|||
|
|
func format() -> String
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The game `index`, ready to show.
|
|||
|
|
*/
|
|||
|
|
func game(index: UInt32) throws -> GameData
|
|||
|
|
|
|||
|
|
func isEmpty() -> Bool
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The number of games.
|
|||
|
|
*/
|
|||
|
|
func len() -> UInt32
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* These games (from [`Database::find`]) from the most recent to the oldest, by the
|
|||
|
|
* time they were played (`UTCDate` and `UTCTime` when there, else `Date`); games of
|
|||
|
|
* the same time keep the newer place in the file first. For downloaded databases,
|
|||
|
|
* where both sites' games are appended oldest first.
|
|||
|
|
*/
|
|||
|
|
func newestFirst(indices: [UInt32]) -> [UInt32]
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Remarks about the conversion, one line each.
|
|||
|
|
*/
|
|||
|
|
func notes() -> [String]
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The game `index` as PGN text, as it is in the file (to copy or share).
|
|||
|
|
*/
|
|||
|
|
func pgn(index: UInt32) -> String?
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The analysis of the game `index` (its report), with earlier results from the
|
|||
|
|
* cache folder `cache_dir` ("" for none) or from `[%eval]` comments of the game.
|
|||
|
|
*/
|
|||
|
|
func review(index: UInt32, cacheDir: String) throws -> GameReview
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Up to `count` lines of the game list from `start` on.
|
|||
|
|
*/
|
|||
|
|
func rows(start: UInt32, count: UInt32) -> [GameRow]
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The rows of these games (from [`Database::find`]), in this order.
|
|||
|
|
*/
|
|||
|
|
func rowsOf(indices: [UInt32]) -> [GameRow]
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The game `index`, to change (moves, variations, its data) and save.
|
|||
|
|
*/
|
|||
|
|
func session(index: UInt32) throws -> GameSession
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Starts preparation for an exact player and colour at `query_fen` (empty means
|
|||
|
|
* the usual initial position). Only the first main-line occurrence in each game
|
|||
|
|
* counts; transpositions count and variations in the database do not. The thread
|
|||
|
|
* is bounded to one active request per database: a new request cancels the old one.
|
|||
|
|
*/
|
|||
|
|
func preparePosition(playerId: UInt32, white: Bool, queryFen: String) throws -> PrepSearch
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Exact-name suggestions, `count` at most 200. An empty query lists all named
|
|||
|
|
* players alphabetically; a non-empty one keeps the catalogue's prefix/games order.
|
|||
|
|
*/
|
|||
|
|
func suggestPlayers(query: String, start: UInt32, count: UInt32) -> PlayerSuggestions
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* An open database.
|
|||
|
|
*/
|
|||
|
|
open class Database: DatabaseProtocol, @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_mobile_api_fn_clone_database(self.handle, $0) }
|
|||
|
|
}
|
|||
|
|
// No primary constructor declared for this class.
|
|||
|
|
|
|||
|
|
deinit {
|
|||
|
|
if handle == 0 {
|
|||
|
|
// Mock objects have handle=0 don't try to free them
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try! rustCall { uniffi_mobile_api_fn_free_database(handle, $0) }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The numbers of the games whose players, event, site, date or opening code (ECO)
|
|||
|
|
* contain every word of `text` (case does not matter); all games for an empty text.
|
|||
|
|
*/
|
|||
|
|
open func find(text: String) -> [UInt32] {
|
|||
|
|
return try! FfiConverterSequenceUInt32.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_database_find(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterString.lower(text),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* What the database was read from ("PGN", "ChessBase", "zip", …).
|
|||
|
|
*/
|
|||
|
|
open func format() -> String {
|
|||
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_database_format(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The game `index`, ready to show.
|
|||
|
|
*/
|
|||
|
|
open func game(index: UInt32)throws -> GameData {
|
|||
|
|
return try FfiConverterTypeGameData_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_database_game(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(index),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
open func isEmpty() -> Bool {
|
|||
|
|
return try! FfiConverterBool.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_database_is_empty(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The number of games.
|
|||
|
|
*/
|
|||
|
|
open func len() -> UInt32 {
|
|||
|
|
return try! FfiConverterUInt32.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_database_len(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* These games (from [`Database::find`]) from the most recent to the oldest, by the
|
|||
|
|
* time they were played (`UTCDate` and `UTCTime` when there, else `Date`); games of
|
|||
|
|
* the same time keep the newer place in the file first. For downloaded databases,
|
|||
|
|
* where both sites' games are appended oldest first.
|
|||
|
|
*/
|
|||
|
|
open func newestFirst(indices: [UInt32]) -> [UInt32] {
|
|||
|
|
return try! FfiConverterSequenceUInt32.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_database_newest_first(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterSequenceUInt32.lower(indices),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Remarks about the conversion, one line each.
|
|||
|
|
*/
|
|||
|
|
open func notes() -> [String] {
|
|||
|
|
return try! FfiConverterSequenceString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_database_notes(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The game `index` as PGN text, as it is in the file (to copy or share).
|
|||
|
|
*/
|
|||
|
|
open func pgn(index: UInt32) -> String? {
|
|||
|
|
return try! FfiConverterOptionString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_database_pgn(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(index),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The analysis of the game `index` (its report), with earlier results from the
|
|||
|
|
* cache folder `cache_dir` ("" for none) or from `[%eval]` comments of the game.
|
|||
|
|
*/
|
|||
|
|
open func review(index: UInt32, cacheDir: String)throws -> GameReview {
|
|||
|
|
return try FfiConverterTypeGameReview_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_database_review(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(index),
|
|||
|
|
FfiConverterString.lower(cacheDir),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Up to `count` lines of the game list from `start` on.
|
|||
|
|
*/
|
|||
|
|
open func rows(start: UInt32, count: UInt32) -> [GameRow] {
|
|||
|
|
return try! FfiConverterSequenceTypeGameRow.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_database_rows(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(start),
|
|||
|
|
FfiConverterUInt32.lower(count),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The rows of these games (from [`Database::find`]), in this order.
|
|||
|
|
*/
|
|||
|
|
open func rowsOf(indices: [UInt32]) -> [GameRow] {
|
|||
|
|
return try! FfiConverterSequenceTypeGameRow.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_database_rows_of(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterSequenceUInt32.lower(indices),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The game `index`, to change (moves, variations, its data) and save.
|
|||
|
|
*/
|
|||
|
|
open func session(index: UInt32)throws -> GameSession {
|
|||
|
|
return try FfiConverterTypeGameSession_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_database_session(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(index),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Starts preparation for an exact player and colour at `query_fen` (empty means
|
|||
|
|
* the usual initial position). Only the first main-line occurrence in each game
|
|||
|
|
* counts; transpositions count and variations in the database do not. The thread
|
|||
|
|
* is bounded to one active request per database: a new request cancels the old one.
|
|||
|
|
*/
|
|||
|
|
open func preparePosition(playerId: UInt32, white: Bool, queryFen: String)throws -> PrepSearch {
|
|||
|
|
return try FfiConverterTypePrepSearch_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_database_prepare_position(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(playerId),
|
|||
|
|
FfiConverterBool.lower(white),
|
|||
|
|
FfiConverterString.lower(queryFen),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Exact-name suggestions, `count` at most 200. An empty query lists all named
|
|||
|
|
* players alphabetically; a non-empty one keeps the catalogue's prefix/games order.
|
|||
|
|
*/
|
|||
|
|
open func suggestPlayers(query: String, start: UInt32, count: UInt32) -> PlayerSuggestions {
|
|||
|
|
return try! FfiConverterTypePlayerSuggestions_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_database_suggest_players(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterString.lower(query),
|
|||
|
|
FfiConverterUInt32.lower(start),
|
|||
|
|
FfiConverterUInt32.lower(count),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeDatabase: FfiConverter {
|
|||
|
|
typealias FfiType = UInt64
|
|||
|
|
typealias SwiftType = Database
|
|||
|
|
|
|||
|
|
public static func lift(_ handle: UInt64) throws -> Database {
|
|||
|
|
return Database(unsafeFromHandle: handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func lower(_ value: Database) -> UInt64 {
|
|||
|
|
return value.uniffiCloneHandle()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Database {
|
|||
|
|
let handle: UInt64 = try readInt(&buf)
|
|||
|
|
return try lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: Database, into buf: inout [UInt8]) {
|
|||
|
|
writeInt(&buf, lower(value))
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeDatabase_lift(_ handle: UInt64) throws -> Database {
|
|||
|
|
return try FfiConverterTypeDatabase.lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeDatabase_lower(_ value: Database) -> UInt64 {
|
|||
|
|
return FfiConverterTypeDatabase.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The analysis of one game.
|
|||
|
|
*/
|
|||
|
|
public protocol GameReviewProtocol: AnyObject, Sendable {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Stops the engine; what it has evaluated is kept (and cached).
|
|||
|
|
*/
|
|||
|
|
func cancel()
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Starts the engine at `path` (with its network `eval_file`, if not empty) on the
|
|||
|
|
* positions without an evaluation, or on all of them when `full` (or when the
|
|||
|
|
* analysis is stale). The search is the fixed one of every game analysis, the same
|
|||
|
|
* as on the desktop. Returns false when there is nothing to analyse. Returns at
|
|||
|
|
* once: the engine starts on its own thread.
|
|||
|
|
*/
|
|||
|
|
func start(path: String, evalFile: String, full: Bool) -> Bool
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The state now, with what the engine has said since the last call.
|
|||
|
|
*/
|
|||
|
|
func state() -> ReviewState
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* The analysis of one game.
|
|||
|
|
*/
|
|||
|
|
open class GameReview: GameReviewProtocol, @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_mobile_api_fn_clone_gamereview(self.handle, $0) }
|
|||
|
|
}
|
|||
|
|
// No primary constructor declared for this class.
|
|||
|
|
|
|||
|
|
deinit {
|
|||
|
|
if handle == 0 {
|
|||
|
|
// Mock objects have handle=0 don't try to free them
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try! rustCall { uniffi_mobile_api_fn_free_gamereview(handle, $0) }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Stops the engine; what it has evaluated is kept (and cached).
|
|||
|
|
*/
|
|||
|
|
open func cancel() {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamereview_cancel(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Starts the engine at `path` (with its network `eval_file`, if not empty) on the
|
|||
|
|
* positions without an evaluation, or on all of them when `full` (or when the
|
|||
|
|
* analysis is stale). The search is the fixed one of every game analysis, the same
|
|||
|
|
* as on the desktop. Returns false when there is nothing to analyse. Returns at
|
|||
|
|
* once: the engine starts on its own thread.
|
|||
|
|
*/
|
|||
|
|
open func start(path: String, evalFile: String, full: Bool) -> Bool {
|
|||
|
|
return try! FfiConverterBool.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamereview_start(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterString.lower(path),
|
|||
|
|
FfiConverterString.lower(evalFile),
|
|||
|
|
FfiConverterBool.lower(full),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The state now, with what the engine has said since the last call.
|
|||
|
|
*/
|
|||
|
|
open func state() -> ReviewState {
|
|||
|
|
return try! FfiConverterTypeReviewState_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamereview_state(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeGameReview: FfiConverter {
|
|||
|
|
typealias FfiType = UInt64
|
|||
|
|
typealias SwiftType = GameReview
|
|||
|
|
|
|||
|
|
public static func lift(_ handle: UInt64) throws -> GameReview {
|
|||
|
|
return GameReview(unsafeFromHandle: handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func lower(_ value: GameReview) -> UInt64 {
|
|||
|
|
return value.uniffiCloneHandle()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GameReview {
|
|||
|
|
let handle: UInt64 = try readInt(&buf)
|
|||
|
|
return try lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: GameReview, into buf: inout [UInt8]) {
|
|||
|
|
writeInt(&buf, lower(value))
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeGameReview_lift(_ handle: UInt64) throws -> GameReview {
|
|||
|
|
return try FfiConverterTypeGameReview.lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeGameReview_lower(_ value: GameReview) -> UInt64 {
|
|||
|
|
return FfiConverterTypeGameReview.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A game that can be changed.
|
|||
|
|
*/
|
|||
|
|
public protocol GameSessionProtocol: AnyObject, Sendable {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* How the game stands at the move at place `at` (its line from the start counts
|
|||
|
|
* for repetitions); none while it goes on.
|
|||
|
|
*/
|
|||
|
|
func ending(at: UInt32) -> GameEnding?
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Adds `text` to the comments after the move at place `at` (its symbols kept).
|
|||
|
|
*/
|
|||
|
|
func addComment(at: UInt32, text: String) throws -> Edited
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Adds a line of moves (an engine's) from place `at`, as `play` does each move.
|
|||
|
|
*/
|
|||
|
|
func addLine(at: UInt32, uci: [String]) throws -> Edited
|
|||
|
|
|
|||
|
|
func canRedo() -> Bool
|
|||
|
|
|
|||
|
|
func canUndo() -> Bool
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The whole game, ready to show.
|
|||
|
|
*/
|
|||
|
|
func data() -> GameData
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes the move at place `at` with all that follows it; shows its parent.
|
|||
|
|
*/
|
|||
|
|
func deleteFrom(at: UInt32) throws -> Edited
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Changed since it was opened or last saved.
|
|||
|
|
*/
|
|||
|
|
func isModified() -> Bool
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The legal moves in the position at place `at`, in UCI ("e2e4", "e7e8q"); none
|
|||
|
|
* after a null move's position cannot go on, at checkmate or stalemate.
|
|||
|
|
*/
|
|||
|
|
func legalMoves(at: UInt32) -> [String]
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Makes the line of the move at place `at` the main one at its branch.
|
|||
|
|
*/
|
|||
|
|
func makeMain(at: UInt32) throws -> Edited
|
|||
|
|
|
|||
|
|
func markSaved()
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The game as PGN, for saving or sharing.
|
|||
|
|
*/
|
|||
|
|
func pgn() -> String
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Plays `uci` from the node at place `at`: the existing continuation when there is
|
|||
|
|
* one (nothing changes), else a new move — the main line where the line ends, a
|
|||
|
|
* variation elsewhere. One undo step.
|
|||
|
|
*/
|
|||
|
|
func play(at: UInt32, uci: String) throws -> Edited
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A new game of the moves from the start to the move at place `at` (to play on from
|
|||
|
|
* there, android-play.md §31.6): the same start position, no tags but those of the
|
|||
|
|
* position. Refused on a null move on the way (a position the board cannot reach).
|
|||
|
|
*/
|
|||
|
|
func playFrom(at: UInt32) throws -> GameSession
|
|||
|
|
|
|||
|
|
func redo() -> Edited?
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The analysis of the game as it is now (its report), with earlier results from
|
|||
|
|
* the cache folder `cache_dir` ("" for none).
|
|||
|
|
*/
|
|||
|
|
func review(cacheDir: String) -> GameReview
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Sets the game's tags (an empty value removes the tag; one of the Seven Tag Roster
|
|||
|
|
* becomes "?") and its result ("1-0", "0-1", "1/2-1/2", "*").
|
|||
|
|
*/
|
|||
|
|
func setData(tags: [Tag], result: String)
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Takes the last change back; `None` when there is none.
|
|||
|
|
*/
|
|||
|
|
func undo() -> Edited?
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A training of the line from the start to the move at place `at` (none: no move
|
|||
|
|
* there, or a null move on the way).
|
|||
|
|
*/
|
|||
|
|
func trainer(at: UInt32) -> Trainer?
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* How many times the line up to the move at place `at` was trained.
|
|||
|
|
*/
|
|||
|
|
func trainingRuns(at: UInt32) -> UInt32?
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* A game that can be changed.
|
|||
|
|
*/
|
|||
|
|
open class GameSession: GameSessionProtocol, @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_mobile_api_fn_clone_gamesession(self.handle, $0) }
|
|||
|
|
}
|
|||
|
|
// No primary constructor declared for this class.
|
|||
|
|
|
|||
|
|
deinit {
|
|||
|
|
if handle == 0 {
|
|||
|
|
// Mock objects have handle=0 don't try to free them
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try! rustCall { uniffi_mobile_api_fn_free_gamesession(handle, $0) }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The first game of a PGN text.
|
|||
|
|
*/
|
|||
|
|
public static func fromPgn(pgn: String)throws -> GameSession {
|
|||
|
|
return try FfiConverterTypeGameSession_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_constructor_gamesession_from_pgn(
|
|||
|
|
FfiConverterString.lower(pgn),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A new game from the start position, dated today (`date`: "2026.10.26").
|
|||
|
|
*/
|
|||
|
|
public static func newGame(date: String) -> GameSession {
|
|||
|
|
return try! FfiConverterTypeGameSession_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_constructor_gamesession_new_game(
|
|||
|
|
FfiConverterString.lower(date),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* How the game stands at the move at place `at` (its line from the start counts
|
|||
|
|
* for repetitions); none while it goes on.
|
|||
|
|
*/
|
|||
|
|
open func ending(at: UInt32) -> GameEnding? {
|
|||
|
|
return try! FfiConverterOptionTypeGameEnding.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_ending(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(at),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Adds `text` to the comments after the move at place `at` (its symbols kept).
|
|||
|
|
*/
|
|||
|
|
open func addComment(at: UInt32, text: String)throws -> Edited {
|
|||
|
|
return try FfiConverterTypeEdited_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_add_comment(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(at),
|
|||
|
|
FfiConverterString.lower(text),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Adds a line of moves (an engine's) from place `at`, as `play` does each move.
|
|||
|
|
*/
|
|||
|
|
open func addLine(at: UInt32, uci: [String])throws -> Edited {
|
|||
|
|
return try FfiConverterTypeEdited_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_add_line(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(at),
|
|||
|
|
FfiConverterSequenceString.lower(uci),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
open func canRedo() -> Bool {
|
|||
|
|
return try! FfiConverterBool.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_can_redo(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
open func canUndo() -> Bool {
|
|||
|
|
return try! FfiConverterBool.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_can_undo(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The whole game, ready to show.
|
|||
|
|
*/
|
|||
|
|
open func data() -> GameData {
|
|||
|
|
return try! FfiConverterTypeGameData_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_data(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Removes the move at place `at` with all that follows it; shows its parent.
|
|||
|
|
*/
|
|||
|
|
open func deleteFrom(at: UInt32)throws -> Edited {
|
|||
|
|
return try FfiConverterTypeEdited_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_delete_from(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(at),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Changed since it was opened or last saved.
|
|||
|
|
*/
|
|||
|
|
open func isModified() -> Bool {
|
|||
|
|
return try! FfiConverterBool.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_is_modified(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The legal moves in the position at place `at`, in UCI ("e2e4", "e7e8q"); none
|
|||
|
|
* after a null move's position cannot go on, at checkmate or stalemate.
|
|||
|
|
*/
|
|||
|
|
open func legalMoves(at: UInt32) -> [String] {
|
|||
|
|
return try! FfiConverterSequenceString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_legal_moves(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(at),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Makes the line of the move at place `at` the main one at its branch.
|
|||
|
|
*/
|
|||
|
|
open func makeMain(at: UInt32)throws -> Edited {
|
|||
|
|
return try FfiConverterTypeEdited_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_make_main(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(at),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
open func markSaved() {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_mark_saved(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The game as PGN, for saving or sharing.
|
|||
|
|
*/
|
|||
|
|
open func pgn() -> String {
|
|||
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_pgn(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Plays `uci` from the node at place `at`: the existing continuation when there is
|
|||
|
|
* one (nothing changes), else a new move — the main line where the line ends, a
|
|||
|
|
* variation elsewhere. One undo step.
|
|||
|
|
*/
|
|||
|
|
open func play(at: UInt32, uci: String)throws -> Edited {
|
|||
|
|
return try FfiConverterTypeEdited_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_play(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(at),
|
|||
|
|
FfiConverterString.lower(uci),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A new game of the moves from the start to the move at place `at` (to play on from
|
|||
|
|
* there, android-play.md §31.6): the same start position, no tags but those of the
|
|||
|
|
* position. Refused on a null move on the way (a position the board cannot reach).
|
|||
|
|
*/
|
|||
|
|
open func playFrom(at: UInt32)throws -> GameSession {
|
|||
|
|
return try FfiConverterTypeGameSession_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_play_from(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(at),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
open func redo() -> Edited? {
|
|||
|
|
return try! FfiConverterOptionTypeEdited.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_redo(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The analysis of the game as it is now (its report), with earlier results from
|
|||
|
|
* the cache folder `cache_dir` ("" for none).
|
|||
|
|
*/
|
|||
|
|
open func review(cacheDir: String) -> GameReview {
|
|||
|
|
return try! FfiConverterTypeGameReview_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_review(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterString.lower(cacheDir),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Sets the game's tags (an empty value removes the tag; one of the Seven Tag Roster
|
|||
|
|
* becomes "?") and its result ("1-0", "0-1", "1/2-1/2", "*").
|
|||
|
|
*/
|
|||
|
|
open func setData(tags: [Tag], result: String) {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_set_data(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterSequenceTypeTag.lower(tags),
|
|||
|
|
FfiConverterString.lower(result),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Takes the last change back; `None` when there is none.
|
|||
|
|
*/
|
|||
|
|
open func undo() -> Edited? {
|
|||
|
|
return try! FfiConverterOptionTypeEdited.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_undo(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A training of the line from the start to the move at place `at` (none: no move
|
|||
|
|
* there, or a null move on the way).
|
|||
|
|
*/
|
|||
|
|
open func trainer(at: UInt32) -> Trainer? {
|
|||
|
|
return try! FfiConverterOptionTypeTrainer.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_trainer(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(at),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* How many times the line up to the move at place `at` was trained.
|
|||
|
|
*/
|
|||
|
|
open func trainingRuns(at: UInt32) -> UInt32? {
|
|||
|
|
return try! FfiConverterOptionUInt32.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_gamesession_training_runs(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(at),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeGameSession: FfiConverter {
|
|||
|
|
typealias FfiType = UInt64
|
|||
|
|
typealias SwiftType = GameSession
|
|||
|
|
|
|||
|
|
public static func lift(_ handle: UInt64) throws -> GameSession {
|
|||
|
|
return GameSession(unsafeFromHandle: handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func lower(_ value: GameSession) -> UInt64 {
|
|||
|
|
return value.uniffiCloneHandle()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GameSession {
|
|||
|
|
let handle: UInt64 = try readInt(&buf)
|
|||
|
|
return try lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: GameSession, into buf: inout [UInt8]) {
|
|||
|
|
writeInt(&buf, lower(value))
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeGameSession_lift(_ handle: UInt64) throws -> GameSession {
|
|||
|
|
return try FfiConverterTypeGameSession.lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeGameSession_lower(_ value: GameSession) -> UInt64 {
|
|||
|
|
return FfiConverterTypeGameSession.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Maia, loaded once for a game.
|
|||
|
|
*/
|
|||
|
|
public protocol MaiaPlayerProtocol: AnyObject, Sendable {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Maia's move (UCI) in the position at place `at` of the game, playing at
|
|||
|
|
* `strength` against a player rated `opponent` (her own strength when unknown).
|
|||
|
|
* `random` is in [0, 1). None when the game is over there.
|
|||
|
|
*/
|
|||
|
|
func choose(game: GameSession, at: UInt32, strength: UInt32, opponent: UInt32?, random: Float) -> String?
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Maia, loaded once for a game.
|
|||
|
|
*/
|
|||
|
|
open class MaiaPlayer: MaiaPlayerProtocol, @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_mobile_api_fn_clone_maiaplayer(self.handle, $0) }
|
|||
|
|
}
|
|||
|
|
// No primary constructor declared for this class.
|
|||
|
|
|
|||
|
|
deinit {
|
|||
|
|
if handle == 0 {
|
|||
|
|
// Mock objects have handle=0 don't try to free them
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try! rustCall { uniffi_mobile_api_fn_free_maiaplayer(handle, $0) }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Reads the weights (`maia3-5m.pt`).
|
|||
|
|
*/
|
|||
|
|
public static func load(path: String)throws -> MaiaPlayer {
|
|||
|
|
return try FfiConverterTypeMaiaPlayer_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_constructor_maiaplayer_load(
|
|||
|
|
FfiConverterString.lower(path),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Maia's move (UCI) in the position at place `at` of the game, playing at
|
|||
|
|
* `strength` against a player rated `opponent` (her own strength when unknown).
|
|||
|
|
* `random` is in [0, 1). None when the game is over there.
|
|||
|
|
*/
|
|||
|
|
open func choose(game: GameSession, at: UInt32, strength: UInt32, opponent: UInt32?, random: Float) -> String? {
|
|||
|
|
return try! FfiConverterOptionString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_maiaplayer_choose(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterTypeGameSession_lower(game),
|
|||
|
|
FfiConverterUInt32.lower(at),
|
|||
|
|
FfiConverterUInt32.lower(strength),
|
|||
|
|
FfiConverterOptionUInt32.lower(opponent),
|
|||
|
|
FfiConverterFloat.lower(random),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeMaiaPlayer: FfiConverter {
|
|||
|
|
typealias FfiType = UInt64
|
|||
|
|
typealias SwiftType = MaiaPlayer
|
|||
|
|
|
|||
|
|
public static func lift(_ handle: UInt64) throws -> MaiaPlayer {
|
|||
|
|
return MaiaPlayer(unsafeFromHandle: handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func lower(_ value: MaiaPlayer) -> UInt64 {
|
|||
|
|
return value.uniffiCloneHandle()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MaiaPlayer {
|
|||
|
|
let handle: UInt64 = try readInt(&buf)
|
|||
|
|
return try lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: MaiaPlayer, into buf: inout [UInt8]) {
|
|||
|
|
writeInt(&buf, lower(value))
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeMaiaPlayer_lift(_ handle: UInt64) throws -> MaiaPlayer {
|
|||
|
|
return try FfiConverterTypeMaiaPlayer.lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeMaiaPlayer_lower(_ value: MaiaPlayer) -> UInt64 {
|
|||
|
|
return FfiConverterTypeMaiaPlayer.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A download of accounts into one database.
|
|||
|
|
*/
|
|||
|
|
public protocol OnlineDownloadProtocol: AnyObject, Sendable {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Stops it soon; what was fetched is kept.
|
|||
|
|
*/
|
|||
|
|
func cancel()
|
|||
|
|
|
|||
|
|
func state() -> DownloadState
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* A download of accounts into one database.
|
|||
|
|
*/
|
|||
|
|
open class OnlineDownload: OnlineDownloadProtocol, @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_mobile_api_fn_clone_onlinedownload(self.handle, $0) }
|
|||
|
|
}
|
|||
|
|
// No primary constructor declared for this class.
|
|||
|
|
|
|||
|
|
deinit {
|
|||
|
|
if handle == 0 {
|
|||
|
|
// Mock objects have handle=0 don't try to free them
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try! rustCall { uniffi_mobile_api_fn_free_onlinedownload(handle, $0) }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Starts fetching the games of `accounts` new since the last time into the database
|
|||
|
|
* at `path` (created when it is not there). Returns at once.
|
|||
|
|
*/
|
|||
|
|
public static func start(accounts: [OnlineAccount], path: String) -> OnlineDownload {
|
|||
|
|
return try! FfiConverterTypeOnlineDownload_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_constructor_onlinedownload_start(
|
|||
|
|
FfiConverterSequenceTypeOnlineAccount.lower(accounts),
|
|||
|
|
FfiConverterString.lower(path),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Stops it soon; what was fetched is kept.
|
|||
|
|
*/
|
|||
|
|
open func cancel() {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_onlinedownload_cancel(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
open func state() -> DownloadState {
|
|||
|
|
return try! FfiConverterTypeDownloadState_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_onlinedownload_state(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeOnlineDownload: FfiConverter {
|
|||
|
|
typealias FfiType = UInt64
|
|||
|
|
typealias SwiftType = OnlineDownload
|
|||
|
|
|
|||
|
|
public static func lift(_ handle: UInt64) throws -> OnlineDownload {
|
|||
|
|
return OnlineDownload(unsafeFromHandle: handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func lower(_ value: OnlineDownload) -> UInt64 {
|
|||
|
|
return value.uniffiCloneHandle()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OnlineDownload {
|
|||
|
|
let handle: UInt64 = try readInt(&buf)
|
|||
|
|
return try lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: OnlineDownload, into buf: inout [UInt8]) {
|
|||
|
|
writeInt(&buf, lower(value))
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeOnlineDownload_lift(_ handle: UInt64) throws -> OnlineDownload {
|
|||
|
|
return try FfiConverterTypeOnlineDownload.lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeOnlineDownload_lower(_ value: OnlineDownload) -> UInt64 {
|
|||
|
|
return FfiConverterTypeOnlineDownload.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* One running or finished position search. Dropping it requests cancellation.
|
|||
|
|
*/
|
|||
|
|
public protocol PrepSearchProtocol: AnyObject, Sendable {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Stops soon; an old worker cannot publish its result afterwards.
|
|||
|
|
*/
|
|||
|
|
func cancel()
|
|||
|
|
|
|||
|
|
func state() -> PrepState
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* One running or finished position search. Dropping it requests cancellation.
|
|||
|
|
*/
|
|||
|
|
open class PrepSearch: PrepSearchProtocol, @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_mobile_api_fn_clone_prepsearch(self.handle, $0) }
|
|||
|
|
}
|
|||
|
|
// No primary constructor declared for this class.
|
|||
|
|
|
|||
|
|
deinit {
|
|||
|
|
if handle == 0 {
|
|||
|
|
// Mock objects have handle=0 don't try to free them
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try! rustCall { uniffi_mobile_api_fn_free_prepsearch(handle, $0) }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Stops soon; an old worker cannot publish its result afterwards.
|
|||
|
|
*/
|
|||
|
|
open func cancel() {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_prepsearch_cancel(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
open func state() -> PrepState {
|
|||
|
|
return try! FfiConverterTypePrepState_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_prepsearch_state(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypePrepSearch: FfiConverter {
|
|||
|
|
typealias FfiType = UInt64
|
|||
|
|
typealias SwiftType = PrepSearch
|
|||
|
|
|
|||
|
|
public static func lift(_ handle: UInt64) throws -> PrepSearch {
|
|||
|
|
return PrepSearch(unsafeFromHandle: handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func lower(_ value: PrepSearch) -> UInt64 {
|
|||
|
|
return value.uniffiCloneHandle()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PrepSearch {
|
|||
|
|
let handle: UInt64 = try readInt(&buf)
|
|||
|
|
return try lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: PrepSearch, into buf: inout [UInt8]) {
|
|||
|
|
writeInt(&buf, lower(value))
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePrepSearch_lift(_ handle: UInt64) throws -> PrepSearch {
|
|||
|
|
return try FfiConverterTypePrepSearch.lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePrepSearch_lower(_ value: PrepSearch) -> UInt64 {
|
|||
|
|
return FfiConverterTypePrepSearch.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Stockfish judging the positions where Maia is to move (unseen by the user), for her
|
|||
|
|
* resignation; one for the whole game.
|
|||
|
|
*/
|
|||
|
|
public protocol ResignJudgeProtocol: AnyObject, Sendable {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Judges the position at place `at` of the game (Maia to move there).
|
|||
|
|
*/
|
|||
|
|
func ask(game: GameSession, at: UInt32)
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Drops the request in flight (its position is gone).
|
|||
|
|
*/
|
|||
|
|
func forget()
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Moves were taken back: the scores of Maia's turns gone are forgotten.
|
|||
|
|
*/
|
|||
|
|
func forgetScores()
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Whether the position asked last is hopeless for Maia, once the answer came.
|
|||
|
|
*/
|
|||
|
|
func hopeless() -> Bool?
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A draw may be offered now (not right after a refusal).
|
|||
|
|
*/
|
|||
|
|
func mayOfferDraw() -> Bool
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The user offers a draw: whether Maia accepts (the shared rule, `play::accepts_draw`).
|
|||
|
|
*/
|
|||
|
|
func offerDraw() -> Bool
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Stockfish judging the positions where Maia is to move (unseen by the user), for her
|
|||
|
|
* resignation; one for the whole game.
|
|||
|
|
*/
|
|||
|
|
open class ResignJudge: ResignJudgeProtocol, @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_mobile_api_fn_clone_resignjudge(self.handle, $0) }
|
|||
|
|
}
|
|||
|
|
// No primary constructor declared for this class.
|
|||
|
|
|
|||
|
|
deinit {
|
|||
|
|
if handle == 0 {
|
|||
|
|
// Mock objects have handle=0 don't try to free them
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try! rustCall { uniffi_mobile_api_fn_free_resignjudge(handle, $0) }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The engine at `path` with its network `eval_file`.
|
|||
|
|
*/
|
|||
|
|
public static func start(path: String, evalFile: String) -> ResignJudge {
|
|||
|
|
return try! FfiConverterTypeResignJudge_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_constructor_resignjudge_start(
|
|||
|
|
FfiConverterString.lower(path),
|
|||
|
|
FfiConverterString.lower(evalFile),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Judges the position at place `at` of the game (Maia to move there).
|
|||
|
|
*/
|
|||
|
|
open func ask(game: GameSession, at: UInt32) {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_resignjudge_ask(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterTypeGameSession_lower(game),
|
|||
|
|
FfiConverterUInt32.lower(at),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Drops the request in flight (its position is gone).
|
|||
|
|
*/
|
|||
|
|
open func forget() {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_resignjudge_forget(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Moves were taken back: the scores of Maia's turns gone are forgotten.
|
|||
|
|
*/
|
|||
|
|
open func forgetScores() {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_resignjudge_forget_scores(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Whether the position asked last is hopeless for Maia, once the answer came.
|
|||
|
|
*/
|
|||
|
|
open func hopeless() -> Bool? {
|
|||
|
|
return try! FfiConverterOptionBool.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_resignjudge_hopeless(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A draw may be offered now (not right after a refusal).
|
|||
|
|
*/
|
|||
|
|
open func mayOfferDraw() -> Bool {
|
|||
|
|
return try! FfiConverterBool.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_resignjudge_may_offer_draw(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The user offers a draw: whether Maia accepts (the shared rule, `play::accepts_draw`).
|
|||
|
|
*/
|
|||
|
|
open func offerDraw() -> Bool {
|
|||
|
|
return try! FfiConverterBool.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_resignjudge_offer_draw(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeResignJudge: FfiConverter {
|
|||
|
|
typealias FfiType = UInt64
|
|||
|
|
typealias SwiftType = ResignJudge
|
|||
|
|
|
|||
|
|
public static func lift(_ handle: UInt64) throws -> ResignJudge {
|
|||
|
|
return ResignJudge(unsafeFromHandle: handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func lower(_ value: ResignJudge) -> UInt64 {
|
|||
|
|
return value.uniffiCloneHandle()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ResignJudge {
|
|||
|
|
let handle: UInt64 = try readInt(&buf)
|
|||
|
|
return try lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: ResignJudge, into buf: inout [UInt8]) {
|
|||
|
|
writeInt(&buf, lower(value))
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeResignJudge_lift(_ handle: UInt64) throws -> ResignJudge {
|
|||
|
|
return try FfiConverterTypeResignJudge.lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeResignJudge_lower(_ value: ResignJudge) -> UInt64 {
|
|||
|
|
return FfiConverterTypeResignJudge.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Rodent IV playing one game (a UCI child process, the shared crate's player).
|
|||
|
|
*/
|
|||
|
|
public protocol RodentPlayerProtocol: AnyObject, Sendable {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Rodent's move (UCI) in the position at place `at` of the game, given after
|
|||
|
|
* `pause_ms` (it thinks meanwhile). Blocks: called off the main thread. None when
|
|||
|
|
* the game is over there, a newer request or `forget` passed it over, or Rodent
|
|||
|
|
* failed.
|
|||
|
|
*/
|
|||
|
|
func choose(game: GameSession, at: UInt32, pauseMs: UInt64) -> String?
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Why Rodent does not play, if it does not.
|
|||
|
|
*/
|
|||
|
|
func failure() -> RodentFailure?
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Drops the request in flight (its position is gone): its `choose` returns none.
|
|||
|
|
*/
|
|||
|
|
func forget()
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Rodent IV playing one game (a UCI child process, the shared crate's player).
|
|||
|
|
*/
|
|||
|
|
open class RodentPlayer: RodentPlayerProtocol, @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_mobile_api_fn_clone_rodentplayer(self.handle, $0) }
|
|||
|
|
}
|
|||
|
|
// No primary constructor declared for this class.
|
|||
|
|
|
|||
|
|
deinit {
|
|||
|
|
if handle == 0 {
|
|||
|
|
// Mock objects have handle=0 don't try to free them
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try! rustCall { uniffi_mobile_api_fn_free_rodentplayer(handle, $0) }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The engine at `exe` with its personalities and books in `home`, playing
|
|||
|
|
* `style_id` at `strength` (its UCI_Elo), with its opening book when `use_book`.
|
|||
|
|
* It starts in the background: a failure is told by [`RodentPlayer::failure`].
|
|||
|
|
*/
|
|||
|
|
public static func start(exe: String, home: String, styleId: String, strength: UInt32, useBook: Bool) -> RodentPlayer {
|
|||
|
|
return try! FfiConverterTypeRodentPlayer_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_constructor_rodentplayer_start(
|
|||
|
|
FfiConverterString.lower(exe),
|
|||
|
|
FfiConverterString.lower(home),
|
|||
|
|
FfiConverterString.lower(styleId),
|
|||
|
|
FfiConverterUInt32.lower(strength),
|
|||
|
|
FfiConverterBool.lower(useBook),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Rodent's move (UCI) in the position at place `at` of the game, given after
|
|||
|
|
* `pause_ms` (it thinks meanwhile). Blocks: called off the main thread. None when
|
|||
|
|
* the game is over there, a newer request or `forget` passed it over, or Rodent
|
|||
|
|
* failed.
|
|||
|
|
*/
|
|||
|
|
open func choose(game: GameSession, at: UInt32, pauseMs: UInt64) -> String? {
|
|||
|
|
return try! FfiConverterOptionString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_rodentplayer_choose(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterTypeGameSession_lower(game),
|
|||
|
|
FfiConverterUInt32.lower(at),
|
|||
|
|
FfiConverterUInt64.lower(pauseMs),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Why Rodent does not play, if it does not.
|
|||
|
|
*/
|
|||
|
|
open func failure() -> RodentFailure? {
|
|||
|
|
return try! FfiConverterOptionTypeRodentFailure.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_rodentplayer_failure(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Drops the request in flight (its position is gone): its `choose` returns none.
|
|||
|
|
*/
|
|||
|
|
open func forget() {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_rodentplayer_forget(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeRodentPlayer: FfiConverter {
|
|||
|
|
typealias FfiType = UInt64
|
|||
|
|
typealias SwiftType = RodentPlayer
|
|||
|
|
|
|||
|
|
public static func lift(_ handle: UInt64) throws -> RodentPlayer {
|
|||
|
|
return RodentPlayer(unsafeFromHandle: handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func lower(_ value: RodentPlayer) -> UInt64 {
|
|||
|
|
return value.uniffiCloneHandle()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RodentPlayer {
|
|||
|
|
let handle: UInt64 = try readInt(&buf)
|
|||
|
|
return try lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: RodentPlayer, into buf: inout [UInt8]) {
|
|||
|
|
writeInt(&buf, lower(value))
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeRodentPlayer_lift(_ handle: UInt64) throws -> RodentPlayer {
|
|||
|
|
return try FfiConverterTypeRodentPlayer.lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeRodentPlayer_lower(_ value: RodentPlayer) -> UInt64 {
|
|||
|
|
return FfiConverterTypeRodentPlayer.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A training of one line.
|
|||
|
|
*/
|
|||
|
|
public protocol TrainerProtocol: AnyObject, Sendable {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The same line again from the start.
|
|||
|
|
*/
|
|||
|
|
func again()
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* «Wijk aan Zee 2024», when the game says so.
|
|||
|
|
*/
|
|||
|
|
func event() -> String?
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The position after a wrong `uci` made after `ply` half-moves (shown a moment).
|
|||
|
|
*/
|
|||
|
|
func fenAfter(ply: UInt32, uci: String) -> String?
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* «Carlsen — Caruana», when the game names its players.
|
|||
|
|
*/
|
|||
|
|
func game() -> String?
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Judges `uci` made after `ply` half-moves.
|
|||
|
|
*/
|
|||
|
|
func judge(ply: UInt32, uci: String) -> TrainVerdict
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The legal moves after `ply` half-moves (UCI).
|
|||
|
|
*/
|
|||
|
|
func legalMoves(ply: UInt32) -> [String]
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The line's move on half-move `ply` in UCI: its piece where a pawn promotes (the
|
|||
|
|
* phone promotes to a queen otherwise, android-play.md §29.4).
|
|||
|
|
*/
|
|||
|
|
func promotionAt(ply: UInt32) -> String?
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Shows the move of half-move `ply` (the run is then «with a hint»).
|
|||
|
|
*/
|
|||
|
|
func show(ply: UInt32)
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The run after `ply` half-moves.
|
|||
|
|
*/
|
|||
|
|
func state(ply: UInt32) -> TrainState
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The line's last move («12…Rd8», SAN in Latin letters).
|
|||
|
|
*/
|
|||
|
|
func upTo() -> String
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* A training of one line.
|
|||
|
|
*/
|
|||
|
|
open class Trainer: TrainerProtocol, @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_mobile_api_fn_clone_trainer(self.handle, $0) }
|
|||
|
|
}
|
|||
|
|
// No primary constructor declared for this class.
|
|||
|
|
|
|||
|
|
deinit {
|
|||
|
|
if handle == 0 {
|
|||
|
|
// Mock objects have handle=0 don't try to free them
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
try! rustCall { uniffi_mobile_api_fn_free_trainer(handle, $0) }
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The same line again from the start.
|
|||
|
|
*/
|
|||
|
|
open func again() {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_trainer_again(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* «Wijk aan Zee 2024», when the game says so.
|
|||
|
|
*/
|
|||
|
|
open func event() -> String? {
|
|||
|
|
return try! FfiConverterOptionString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_trainer_event(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The position after a wrong `uci` made after `ply` half-moves (shown a moment).
|
|||
|
|
*/
|
|||
|
|
open func fenAfter(ply: UInt32, uci: String) -> String? {
|
|||
|
|
return try! FfiConverterOptionString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_trainer_fen_after(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(ply),
|
|||
|
|
FfiConverterString.lower(uci),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* «Carlsen — Caruana», when the game names its players.
|
|||
|
|
*/
|
|||
|
|
open func game() -> String? {
|
|||
|
|
return try! FfiConverterOptionString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_trainer_game(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Judges `uci` made after `ply` half-moves.
|
|||
|
|
*/
|
|||
|
|
open func judge(ply: UInt32, uci: String) -> TrainVerdict {
|
|||
|
|
return try! FfiConverterTypeTrainVerdict_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_trainer_judge(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(ply),
|
|||
|
|
FfiConverterString.lower(uci),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The legal moves after `ply` half-moves (UCI).
|
|||
|
|
*/
|
|||
|
|
open func legalMoves(ply: UInt32) -> [String] {
|
|||
|
|
return try! FfiConverterSequenceString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_trainer_legal_moves(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(ply),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The line's move on half-move `ply` in UCI: its piece where a pawn promotes (the
|
|||
|
|
* phone promotes to a queen otherwise, android-play.md §29.4).
|
|||
|
|
*/
|
|||
|
|
open func promotionAt(ply: UInt32) -> String? {
|
|||
|
|
return try! FfiConverterOptionString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_trainer_promotion_at(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(ply),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Shows the move of half-move `ply` (the run is then «with a hint»).
|
|||
|
|
*/
|
|||
|
|
open func show(ply: UInt32) {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_trainer_show(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(ply),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The run after `ply` half-moves.
|
|||
|
|
*/
|
|||
|
|
open func state(ply: UInt32) -> TrainState {
|
|||
|
|
return try! FfiConverterTypeTrainState_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_trainer_state(
|
|||
|
|
self.uniffiCloneHandle(),
|
|||
|
|
FfiConverterUInt32.lower(ply),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The line's last move («12…Rd8», SAN in Latin letters).
|
|||
|
|
*/
|
|||
|
|
open func upTo() -> String {
|
|||
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_method_trainer_up_to(
|
|||
|
|
self.uniffiCloneHandle(),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeTrainer: FfiConverter {
|
|||
|
|
typealias FfiType = UInt64
|
|||
|
|
typealias SwiftType = Trainer
|
|||
|
|
|
|||
|
|
public static func lift(_ handle: UInt64) throws -> Trainer {
|
|||
|
|
return Trainer(unsafeFromHandle: handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func lower(_ value: Trainer) -> UInt64 {
|
|||
|
|
return value.uniffiCloneHandle()
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Trainer {
|
|||
|
|
let handle: UInt64 = try readInt(&buf)
|
|||
|
|
return try lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: Trainer, into buf: inout [UInt8]) {
|
|||
|
|
writeInt(&buf, lower(value))
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeTrainer_lift(_ handle: UInt64) throws -> Trainer {
|
|||
|
|
return try FfiConverterTypeTrainer.lift(handle)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeTrainer_lower(_ value: Trainer) -> UInt64 {
|
|||
|
|
return FfiConverterTypeTrainer.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* What the engine says about the position of `search`.
|
|||
|
|
*/
|
|||
|
|
public struct Analysis: Equatable, Hashable {
|
|||
|
|
public var search: UInt64
|
|||
|
|
public var depth: UInt32
|
|||
|
|
public var nodesPerSecond: UInt64
|
|||
|
|
/**
|
|||
|
|
* Ordered by `multipv`.
|
|||
|
|
*/
|
|||
|
|
public var lines: [EngineLine]
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(search: UInt64, depth: UInt32, nodesPerSecond: UInt64,
|
|||
|
|
/**
|
|||
|
|
* Ordered by `multipv`.
|
|||
|
|
*/lines: [EngineLine]) {
|
|||
|
|
self.search = search
|
|||
|
|
self.depth = depth
|
|||
|
|
self.nodesPerSecond = nodesPerSecond
|
|||
|
|
self.lines = lines
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension Analysis: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeAnalysis: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Analysis {
|
|||
|
|
return
|
|||
|
|
try Analysis(
|
|||
|
|
search: FfiConverterUInt64.read(from: &buf),
|
|||
|
|
depth: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
nodesPerSecond: FfiConverterUInt64.read(from: &buf),
|
|||
|
|
lines: FfiConverterSequenceTypeEngineLine.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: Analysis, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterUInt64.write(value.search, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.depth, into: &buf)
|
|||
|
|
FfiConverterUInt64.write(value.nodesPerSecond, into: &buf)
|
|||
|
|
FfiConverterSequenceTypeEngineLine.write(value.lines, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeAnalysis_lift(_ buf: RustBuffer) throws -> Analysis {
|
|||
|
|
return try FfiConverterTypeAnalysis.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeAnalysis_lower(_ value: Analysis) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeAnalysis.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* An APK of a release.
|
|||
|
|
*/
|
|||
|
|
public struct ApkFile: Equatable, Hashable {
|
|||
|
|
public var name: String
|
|||
|
|
public var url: String
|
|||
|
|
public var size: UInt64
|
|||
|
|
/**
|
|||
|
|
* From the release's `SHA256SUMS.txt`, lowercase hex.
|
|||
|
|
*/
|
|||
|
|
public var sha256: String
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(name: String, url: String, size: UInt64,
|
|||
|
|
/**
|
|||
|
|
* From the release's `SHA256SUMS.txt`, lowercase hex.
|
|||
|
|
*/sha256: String) {
|
|||
|
|
self.name = name
|
|||
|
|
self.url = url
|
|||
|
|
self.size = size
|
|||
|
|
self.sha256 = sha256
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension ApkFile: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeApkFile: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ApkFile {
|
|||
|
|
return
|
|||
|
|
try ApkFile(
|
|||
|
|
name: FfiConverterString.read(from: &buf),
|
|||
|
|
url: FfiConverterString.read(from: &buf),
|
|||
|
|
size: FfiConverterUInt64.read(from: &buf),
|
|||
|
|
sha256: FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: ApkFile, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterString.write(value.name, into: &buf)
|
|||
|
|
FfiConverterString.write(value.url, into: &buf)
|
|||
|
|
FfiConverterUInt64.write(value.size, into: &buf)
|
|||
|
|
FfiConverterString.write(value.sha256, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeApkFile_lift(_ buf: RustBuffer) throws -> ApkFile {
|
|||
|
|
return try FfiConverterTypeApkFile.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeApkFile_lower(_ value: ApkFile) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeApkFile.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A release newer than this app.
|
|||
|
|
*/
|
|||
|
|
public struct AppRelease: Equatable, Hashable {
|
|||
|
|
public var version: String
|
|||
|
|
/**
|
|||
|
|
* Its page: what is new in it.
|
|||
|
|
*/
|
|||
|
|
public var page: String
|
|||
|
|
/**
|
|||
|
|
* The build without the engine's network (the network already in the app stays).
|
|||
|
|
*/
|
|||
|
|
public var light: ApkFile?
|
|||
|
|
/**
|
|||
|
|
* The build with the network inside.
|
|||
|
|
*/
|
|||
|
|
public var full: ApkFile?
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(version: String,
|
|||
|
|
/**
|
|||
|
|
* Its page: what is new in it.
|
|||
|
|
*/page: String,
|
|||
|
|
/**
|
|||
|
|
* The build without the engine's network (the network already in the app stays).
|
|||
|
|
*/light: ApkFile?,
|
|||
|
|
/**
|
|||
|
|
* The build with the network inside.
|
|||
|
|
*/full: ApkFile?) {
|
|||
|
|
self.version = version
|
|||
|
|
self.page = page
|
|||
|
|
self.light = light
|
|||
|
|
self.full = full
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension AppRelease: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeAppRelease: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AppRelease {
|
|||
|
|
return
|
|||
|
|
try AppRelease(
|
|||
|
|
version: FfiConverterString.read(from: &buf),
|
|||
|
|
page: FfiConverterString.read(from: &buf),
|
|||
|
|
light: FfiConverterOptionTypeApkFile.read(from: &buf),
|
|||
|
|
full: FfiConverterOptionTypeApkFile.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: AppRelease, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterString.write(value.version, into: &buf)
|
|||
|
|
FfiConverterString.write(value.page, into: &buf)
|
|||
|
|
FfiConverterOptionTypeApkFile.write(value.light, into: &buf)
|
|||
|
|
FfiConverterOptionTypeApkFile.write(value.full, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeAppRelease_lift(_ buf: RustBuffer) throws -> AppRelease {
|
|||
|
|
return try FfiConverterTypeAppRelease.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeAppRelease_lower(_ value: AppRelease) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeAppRelease.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* How a download stands.
|
|||
|
|
*/
|
|||
|
|
public struct DownloadState: Equatable, Hashable {
|
|||
|
|
public var running: Bool
|
|||
|
|
/**
|
|||
|
|
* The account being fetched (an index into the download's accounts).
|
|||
|
|
*/
|
|||
|
|
public var account: UInt32
|
|||
|
|
/**
|
|||
|
|
* Games of that account so far.
|
|||
|
|
*/
|
|||
|
|
public var accountGames: UInt64
|
|||
|
|
/**
|
|||
|
|
* Games added by this download so far.
|
|||
|
|
*/
|
|||
|
|
public var added: UInt64
|
|||
|
|
/**
|
|||
|
|
* Chess.com: months done of all.
|
|||
|
|
*/
|
|||
|
|
public var monthsDone: UInt32
|
|||
|
|
public var monthsTotal: UInt32
|
|||
|
|
/**
|
|||
|
|
* When it has ended: the games added and in the database now; stopped by the user.
|
|||
|
|
*/
|
|||
|
|
public var total: UInt64?
|
|||
|
|
public var cancelled: Bool
|
|||
|
|
public var failure: OnlineFailure?
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(running: Bool,
|
|||
|
|
/**
|
|||
|
|
* The account being fetched (an index into the download's accounts).
|
|||
|
|
*/account: UInt32,
|
|||
|
|
/**
|
|||
|
|
* Games of that account so far.
|
|||
|
|
*/accountGames: UInt64,
|
|||
|
|
/**
|
|||
|
|
* Games added by this download so far.
|
|||
|
|
*/added: UInt64,
|
|||
|
|
/**
|
|||
|
|
* Chess.com: months done of all.
|
|||
|
|
*/monthsDone: UInt32, monthsTotal: UInt32,
|
|||
|
|
/**
|
|||
|
|
* When it has ended: the games added and in the database now; stopped by the user.
|
|||
|
|
*/total: UInt64?, cancelled: Bool, failure: OnlineFailure?) {
|
|||
|
|
self.running = running
|
|||
|
|
self.account = account
|
|||
|
|
self.accountGames = accountGames
|
|||
|
|
self.added = added
|
|||
|
|
self.monthsDone = monthsDone
|
|||
|
|
self.monthsTotal = monthsTotal
|
|||
|
|
self.total = total
|
|||
|
|
self.cancelled = cancelled
|
|||
|
|
self.failure = failure
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension DownloadState: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeDownloadState: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DownloadState {
|
|||
|
|
return
|
|||
|
|
try DownloadState(
|
|||
|
|
running: FfiConverterBool.read(from: &buf),
|
|||
|
|
account: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
accountGames: FfiConverterUInt64.read(from: &buf),
|
|||
|
|
added: FfiConverterUInt64.read(from: &buf),
|
|||
|
|
monthsDone: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
monthsTotal: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
total: FfiConverterOptionUInt64.read(from: &buf),
|
|||
|
|
cancelled: FfiConverterBool.read(from: &buf),
|
|||
|
|
failure: FfiConverterOptionTypeOnlineFailure.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: DownloadState, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterBool.write(value.running, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.account, into: &buf)
|
|||
|
|
FfiConverterUInt64.write(value.accountGames, into: &buf)
|
|||
|
|
FfiConverterUInt64.write(value.added, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.monthsDone, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.monthsTotal, into: &buf)
|
|||
|
|
FfiConverterOptionUInt64.write(value.total, into: &buf)
|
|||
|
|
FfiConverterBool.write(value.cancelled, into: &buf)
|
|||
|
|
FfiConverterOptionTypeOnlineFailure.write(value.failure, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeDownloadState_lift(_ buf: RustBuffer) throws -> DownloadState {
|
|||
|
|
return try FfiConverterTypeDownloadState.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeDownloadState_lower(_ value: DownloadState) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeDownloadState.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A game after a change: all of it again (the ids are places in `data.nodes`, which a
|
|||
|
|
* change may move) and the node to show.
|
|||
|
|
*/
|
|||
|
|
public struct Edited: Equatable, Hashable {
|
|||
|
|
public var data: GameData
|
|||
|
|
public var cursor: UInt32
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(data: GameData, cursor: UInt32) {
|
|||
|
|
self.data = data
|
|||
|
|
self.cursor = cursor
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension Edited: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeEdited: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Edited {
|
|||
|
|
return
|
|||
|
|
try Edited(
|
|||
|
|
data: FfiConverterTypeGameData.read(from: &buf),
|
|||
|
|
cursor: FfiConverterUInt32.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: Edited, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterTypeGameData.write(value.data, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.cursor, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeEdited_lift(_ buf: RustBuffer) throws -> Edited {
|
|||
|
|
return try FfiConverterTypeEdited.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeEdited_lower(_ value: Edited) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeEdited.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* One line of the analysis, from White's point of view.
|
|||
|
|
*/
|
|||
|
|
public struct EngineLine: Equatable, Hashable {
|
|||
|
|
/**
|
|||
|
|
* 1 for the best line.
|
|||
|
|
*/
|
|||
|
|
public var multipv: UInt32
|
|||
|
|
/**
|
|||
|
|
* "+0.45", "−1.20", "0.00", "#3" (White mates), "#−2" (Black mates).
|
|||
|
|
*/
|
|||
|
|
public var eval: String
|
|||
|
|
/**
|
|||
|
|
* Centipawns for White, when the score is not a mate.
|
|||
|
|
*/
|
|||
|
|
public var cp: Int32?
|
|||
|
|
/**
|
|||
|
|
* Moves to mate: positive when White mates, negative when Black mates.
|
|||
|
|
*/
|
|||
|
|
public var mate: Int32?
|
|||
|
|
/**
|
|||
|
|
* The line in SAN with move numbers: "14.Nd5 Bxd5 15.exd5".
|
|||
|
|
*/
|
|||
|
|
public var text: String
|
|||
|
|
/**
|
|||
|
|
* The squares of its first move, for an arrow on the board.
|
|||
|
|
*/
|
|||
|
|
public var fromSquare: String?
|
|||
|
|
public var toSquare: String?
|
|||
|
|
/**
|
|||
|
|
* The line move by move, to show it on the board without touching the game.
|
|||
|
|
*/
|
|||
|
|
public var steps: [LineStep]
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(
|
|||
|
|
/**
|
|||
|
|
* 1 for the best line.
|
|||
|
|
*/multipv: UInt32,
|
|||
|
|
/**
|
|||
|
|
* "+0.45", "−1.20", "0.00", "#3" (White mates), "#−2" (Black mates).
|
|||
|
|
*/eval: String,
|
|||
|
|
/**
|
|||
|
|
* Centipawns for White, when the score is not a mate.
|
|||
|
|
*/cp: Int32?,
|
|||
|
|
/**
|
|||
|
|
* Moves to mate: positive when White mates, negative when Black mates.
|
|||
|
|
*/mate: Int32?,
|
|||
|
|
/**
|
|||
|
|
* The line in SAN with move numbers: "14.Nd5 Bxd5 15.exd5".
|
|||
|
|
*/text: String,
|
|||
|
|
/**
|
|||
|
|
* The squares of its first move, for an arrow on the board.
|
|||
|
|
*/fromSquare: String?, toSquare: String?,
|
|||
|
|
/**
|
|||
|
|
* The line move by move, to show it on the board without touching the game.
|
|||
|
|
*/steps: [LineStep]) {
|
|||
|
|
self.multipv = multipv
|
|||
|
|
self.eval = eval
|
|||
|
|
self.cp = cp
|
|||
|
|
self.mate = mate
|
|||
|
|
self.text = text
|
|||
|
|
self.fromSquare = fromSquare
|
|||
|
|
self.toSquare = toSquare
|
|||
|
|
self.steps = steps
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension EngineLine: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeEngineLine: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> EngineLine {
|
|||
|
|
return
|
|||
|
|
try EngineLine(
|
|||
|
|
multipv: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
eval: FfiConverterString.read(from: &buf),
|
|||
|
|
cp: FfiConverterOptionInt32.read(from: &buf),
|
|||
|
|
mate: FfiConverterOptionInt32.read(from: &buf),
|
|||
|
|
text: FfiConverterString.read(from: &buf),
|
|||
|
|
fromSquare: FfiConverterOptionString.read(from: &buf),
|
|||
|
|
toSquare: FfiConverterOptionString.read(from: &buf),
|
|||
|
|
steps: FfiConverterSequenceTypeLineStep.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: EngineLine, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterUInt32.write(value.multipv, into: &buf)
|
|||
|
|
FfiConverterString.write(value.eval, into: &buf)
|
|||
|
|
FfiConverterOptionInt32.write(value.cp, into: &buf)
|
|||
|
|
FfiConverterOptionInt32.write(value.mate, into: &buf)
|
|||
|
|
FfiConverterString.write(value.text, into: &buf)
|
|||
|
|
FfiConverterOptionString.write(value.fromSquare, into: &buf)
|
|||
|
|
FfiConverterOptionString.write(value.toSquare, into: &buf)
|
|||
|
|
FfiConverterSequenceTypeLineStep.write(value.steps, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeEngineLine_lift(_ buf: RustBuffer) throws -> EngineLine {
|
|||
|
|
return try FfiConverterTypeEngineLine.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeEngineLine_lower(_ value: EngineLine) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeEngineLine.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A file of a ChessBase database folder: its name and descriptor (taken over).
|
|||
|
|
*/
|
|||
|
|
public struct FolderFile: Equatable, Hashable {
|
|||
|
|
public var name: String
|
|||
|
|
public var fd: Int32
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(name: String, fd: Int32) {
|
|||
|
|
self.name = name
|
|||
|
|
self.fd = fd
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension FolderFile: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeFolderFile: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FolderFile {
|
|||
|
|
return
|
|||
|
|
try FolderFile(
|
|||
|
|
name: FfiConverterString.read(from: &buf),
|
|||
|
|
fd: FfiConverterInt32.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: FolderFile, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterString.write(value.name, into: &buf)
|
|||
|
|
FfiConverterInt32.write(value.fd, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeFolderFile_lift(_ buf: RustBuffer) throws -> FolderFile {
|
|||
|
|
return try FfiConverterTypeFolderFile.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeFolderFile_lower(_ value: FolderFile) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeFolderFile.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A game ready to show.
|
|||
|
|
*/
|
|||
|
|
public struct GameData: Equatable, Hashable {
|
|||
|
|
public var tags: [Tag]
|
|||
|
|
public var result: String
|
|||
|
|
/**
|
|||
|
|
* Every node: `nodes[0]` is the root; a node's id is its place in this list.
|
|||
|
|
*/
|
|||
|
|
public var nodes: [MoveNode]
|
|||
|
|
/**
|
|||
|
|
* Problems found reading the game, one line each.
|
|||
|
|
*/
|
|||
|
|
public var notes: [String]
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(tags: [Tag], result: String,
|
|||
|
|
/**
|
|||
|
|
* Every node: `nodes[0]` is the root; a node's id is its place in this list.
|
|||
|
|
*/nodes: [MoveNode],
|
|||
|
|
/**
|
|||
|
|
* Problems found reading the game, one line each.
|
|||
|
|
*/notes: [String]) {
|
|||
|
|
self.tags = tags
|
|||
|
|
self.result = result
|
|||
|
|
self.nodes = nodes
|
|||
|
|
self.notes = notes
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension GameData: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeGameData: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GameData {
|
|||
|
|
return
|
|||
|
|
try GameData(
|
|||
|
|
tags: FfiConverterSequenceTypeTag.read(from: &buf),
|
|||
|
|
result: FfiConverterString.read(from: &buf),
|
|||
|
|
nodes: FfiConverterSequenceTypeMoveNode.read(from: &buf),
|
|||
|
|
notes: FfiConverterSequenceString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: GameData, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterSequenceTypeTag.write(value.tags, into: &buf)
|
|||
|
|
FfiConverterString.write(value.result, into: &buf)
|
|||
|
|
FfiConverterSequenceTypeMoveNode.write(value.nodes, into: &buf)
|
|||
|
|
FfiConverterSequenceString.write(value.notes, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeGameData_lift(_ buf: RustBuffer) throws -> GameData {
|
|||
|
|
return try FfiConverterTypeGameData.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeGameData_lower(_ value: GameData) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeGameData.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* One line of the game list.
|
|||
|
|
*/
|
|||
|
|
public struct GameRow: Equatable, Hashable {
|
|||
|
|
/**
|
|||
|
|
* The game's number in the database (0-based), for [`Database::game`].
|
|||
|
|
*/
|
|||
|
|
public var index: UInt32
|
|||
|
|
public var white: String
|
|||
|
|
public var black: String
|
|||
|
|
/**
|
|||
|
|
* "1-0", "0-1", "1/2-1/2" or "*".
|
|||
|
|
*/
|
|||
|
|
public var result: String
|
|||
|
|
/**
|
|||
|
|
* As in PGN: "1858.??.??".
|
|||
|
|
*/
|
|||
|
|
public var date: String
|
|||
|
|
public var event: String
|
|||
|
|
public var eco: String
|
|||
|
|
public var whiteElo: String
|
|||
|
|
public var blackElo: String
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(
|
|||
|
|
/**
|
|||
|
|
* The game's number in the database (0-based), for [`Database::game`].
|
|||
|
|
*/index: UInt32, white: String, black: String,
|
|||
|
|
/**
|
|||
|
|
* "1-0", "0-1", "1/2-1/2" or "*".
|
|||
|
|
*/result: String,
|
|||
|
|
/**
|
|||
|
|
* As in PGN: "1858.??.??".
|
|||
|
|
*/date: String, event: String, eco: String, whiteElo: String, blackElo: String) {
|
|||
|
|
self.index = index
|
|||
|
|
self.white = white
|
|||
|
|
self.black = black
|
|||
|
|
self.result = result
|
|||
|
|
self.date = date
|
|||
|
|
self.event = event
|
|||
|
|
self.eco = eco
|
|||
|
|
self.whiteElo = whiteElo
|
|||
|
|
self.blackElo = blackElo
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension GameRow: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeGameRow: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GameRow {
|
|||
|
|
return
|
|||
|
|
try GameRow(
|
|||
|
|
index: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
white: FfiConverterString.read(from: &buf),
|
|||
|
|
black: FfiConverterString.read(from: &buf),
|
|||
|
|
result: FfiConverterString.read(from: &buf),
|
|||
|
|
date: FfiConverterString.read(from: &buf),
|
|||
|
|
event: FfiConverterString.read(from: &buf),
|
|||
|
|
eco: FfiConverterString.read(from: &buf),
|
|||
|
|
whiteElo: FfiConverterString.read(from: &buf),
|
|||
|
|
blackElo: FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: GameRow, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterUInt32.write(value.index, into: &buf)
|
|||
|
|
FfiConverterString.write(value.white, into: &buf)
|
|||
|
|
FfiConverterString.write(value.black, into: &buf)
|
|||
|
|
FfiConverterString.write(value.result, into: &buf)
|
|||
|
|
FfiConverterString.write(value.date, into: &buf)
|
|||
|
|
FfiConverterString.write(value.event, into: &buf)
|
|||
|
|
FfiConverterString.write(value.eco, into: &buf)
|
|||
|
|
FfiConverterString.write(value.whiteElo, into: &buf)
|
|||
|
|
FfiConverterString.write(value.blackElo, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeGameRow_lift(_ buf: RustBuffer) throws -> GameRow {
|
|||
|
|
return try FfiConverterTypeGameRow.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeGameRow_lower(_ value: GameRow) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeGameRow.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A move of an engine line and the position after it.
|
|||
|
|
*/
|
|||
|
|
public struct LineStep: Equatable, Hashable {
|
|||
|
|
/**
|
|||
|
|
* "14.Nd5", "14…Bxd5".
|
|||
|
|
*/
|
|||
|
|
public var label: String
|
|||
|
|
public var fen: String
|
|||
|
|
public var fromSquare: String
|
|||
|
|
public var toSquare: String
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(
|
|||
|
|
/**
|
|||
|
|
* "14.Nd5", "14…Bxd5".
|
|||
|
|
*/label: String, fen: String, fromSquare: String, toSquare: String) {
|
|||
|
|
self.label = label
|
|||
|
|
self.fen = fen
|
|||
|
|
self.fromSquare = fromSquare
|
|||
|
|
self.toSquare = toSquare
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension LineStep: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeLineStep: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LineStep {
|
|||
|
|
return
|
|||
|
|
try LineStep(
|
|||
|
|
label: FfiConverterString.read(from: &buf),
|
|||
|
|
fen: FfiConverterString.read(from: &buf),
|
|||
|
|
fromSquare: FfiConverterString.read(from: &buf),
|
|||
|
|
toSquare: FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: LineStep, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterString.write(value.label, into: &buf)
|
|||
|
|
FfiConverterString.write(value.fen, into: &buf)
|
|||
|
|
FfiConverterString.write(value.fromSquare, into: &buf)
|
|||
|
|
FfiConverterString.write(value.toSquare, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeLineStep_lift(_ buf: RustBuffer) throws -> LineStep {
|
|||
|
|
return try FfiConverterTypeLineStep.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeLineStep_lower(_ value: LineStep) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeLineStep.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* An arrow (`to` set) or a marked square of a comment, in a comment color:
|
|||
|
|
* 'R', 'G', 'B', 'Y' or another letter.
|
|||
|
|
*/
|
|||
|
|
public struct Mark: Equatable, Hashable {
|
|||
|
|
public var color: String
|
|||
|
|
public var from: String
|
|||
|
|
public var to: String?
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(color: String, from: String, to: String?) {
|
|||
|
|
self.color = color
|
|||
|
|
self.from = from
|
|||
|
|
self.to = to
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension Mark: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeMark: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Mark {
|
|||
|
|
return
|
|||
|
|
try Mark(
|
|||
|
|
color: FfiConverterString.read(from: &buf),
|
|||
|
|
from: FfiConverterString.read(from: &buf),
|
|||
|
|
to: FfiConverterOptionString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: Mark, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterString.write(value.color, into: &buf)
|
|||
|
|
FfiConverterString.write(value.from, into: &buf)
|
|||
|
|
FfiConverterOptionString.write(value.to, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeMark_lift(_ buf: RustBuffer) throws -> Mark {
|
|||
|
|
return try FfiConverterTypeMark.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeMark_lower(_ value: Mark) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeMark.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A position in the game: the root (the start position) or the one after a move.
|
|||
|
|
*/
|
|||
|
|
public struct MoveNode: Equatable, Hashable {
|
|||
|
|
/**
|
|||
|
|
* The node's id (the root is 0); `children` and `parent` refer to these.
|
|||
|
|
*/
|
|||
|
|
public var id: UInt32
|
|||
|
|
public var parent: UInt32?
|
|||
|
|
/**
|
|||
|
|
* The moves from here: the main line first, then the variations.
|
|||
|
|
*/
|
|||
|
|
public var children: [UInt32]
|
|||
|
|
/**
|
|||
|
|
* SAN of the move that led here ("" for the root), always Latin letters.
|
|||
|
|
*/
|
|||
|
|
public var san: String
|
|||
|
|
/**
|
|||
|
|
* The move's number and side: 12 and true for "12.Nf3", 12 and false for "12…Nf6".
|
|||
|
|
*/
|
|||
|
|
public var moveNumber: UInt32
|
|||
|
|
public var white: Bool
|
|||
|
|
/**
|
|||
|
|
* Numeric annotation glyphs ($1 = "!") and their symbols ("!", "+-", …).
|
|||
|
|
*/
|
|||
|
|
public var nags: Data
|
|||
|
|
public var nagSymbols: String
|
|||
|
|
/**
|
|||
|
|
* Comments as shown: board commands left out, lines reflowed.
|
|||
|
|
*/
|
|||
|
|
public var commentBefore: String
|
|||
|
|
public var commentAfter: String
|
|||
|
|
/**
|
|||
|
|
* The position here, and the squares of the move that led to it (for highlighting).
|
|||
|
|
*/
|
|||
|
|
public var fen: String
|
|||
|
|
public var fromSquare: String?
|
|||
|
|
public var toSquare: String?
|
|||
|
|
/**
|
|||
|
|
* A null move ("--") of a study.
|
|||
|
|
*/
|
|||
|
|
public var nullMove: Bool
|
|||
|
|
/**
|
|||
|
|
* The move in UCI notation, for the engine's history; empty for the root and a
|
|||
|
|
* null move (after which the engine gets the position as a FEN).
|
|||
|
|
*/
|
|||
|
|
public var uci: String
|
|||
|
|
/**
|
|||
|
|
* Arrows (`[%cal]`) and marked squares (`[%csl]`) of the comments after the move.
|
|||
|
|
*/
|
|||
|
|
public var marks: [Mark]
|
|||
|
|
/**
|
|||
|
|
* "checkmate" or "stalemate" when the game cannot go on from here; "" otherwise.
|
|||
|
|
*/
|
|||
|
|
public var end: String
|
|||
|
|
/**
|
|||
|
|
* On the main line of the game (not inside a variation).
|
|||
|
|
*/
|
|||
|
|
public var mainLine: Bool
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(
|
|||
|
|
/**
|
|||
|
|
* The node's id (the root is 0); `children` and `parent` refer to these.
|
|||
|
|
*/id: UInt32, parent: UInt32?,
|
|||
|
|
/**
|
|||
|
|
* The moves from here: the main line first, then the variations.
|
|||
|
|
*/children: [UInt32],
|
|||
|
|
/**
|
|||
|
|
* SAN of the move that led here ("" for the root), always Latin letters.
|
|||
|
|
*/san: String,
|
|||
|
|
/**
|
|||
|
|
* The move's number and side: 12 and true for "12.Nf3", 12 and false for "12…Nf6".
|
|||
|
|
*/moveNumber: UInt32, white: Bool,
|
|||
|
|
/**
|
|||
|
|
* Numeric annotation glyphs ($1 = "!") and their symbols ("!", "+-", …).
|
|||
|
|
*/nags: Data, nagSymbols: String,
|
|||
|
|
/**
|
|||
|
|
* Comments as shown: board commands left out, lines reflowed.
|
|||
|
|
*/commentBefore: String, commentAfter: String,
|
|||
|
|
/**
|
|||
|
|
* The position here, and the squares of the move that led to it (for highlighting).
|
|||
|
|
*/fen: String, fromSquare: String?, toSquare: String?,
|
|||
|
|
/**
|
|||
|
|
* A null move ("--") of a study.
|
|||
|
|
*/nullMove: Bool,
|
|||
|
|
/**
|
|||
|
|
* The move in UCI notation, for the engine's history; empty for the root and a
|
|||
|
|
* null move (after which the engine gets the position as a FEN).
|
|||
|
|
*/uci: String,
|
|||
|
|
/**
|
|||
|
|
* Arrows (`[%cal]`) and marked squares (`[%csl]`) of the comments after the move.
|
|||
|
|
*/marks: [Mark],
|
|||
|
|
/**
|
|||
|
|
* "checkmate" or "stalemate" when the game cannot go on from here; "" otherwise.
|
|||
|
|
*/end: String,
|
|||
|
|
/**
|
|||
|
|
* On the main line of the game (not inside a variation).
|
|||
|
|
*/mainLine: Bool) {
|
|||
|
|
self.id = id
|
|||
|
|
self.parent = parent
|
|||
|
|
self.children = children
|
|||
|
|
self.san = san
|
|||
|
|
self.moveNumber = moveNumber
|
|||
|
|
self.white = white
|
|||
|
|
self.nags = nags
|
|||
|
|
self.nagSymbols = nagSymbols
|
|||
|
|
self.commentBefore = commentBefore
|
|||
|
|
self.commentAfter = commentAfter
|
|||
|
|
self.fen = fen
|
|||
|
|
self.fromSquare = fromSquare
|
|||
|
|
self.toSquare = toSquare
|
|||
|
|
self.nullMove = nullMove
|
|||
|
|
self.uci = uci
|
|||
|
|
self.marks = marks
|
|||
|
|
self.end = end
|
|||
|
|
self.mainLine = mainLine
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension MoveNode: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeMoveNode: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MoveNode {
|
|||
|
|
return
|
|||
|
|
try MoveNode(
|
|||
|
|
id: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
parent: FfiConverterOptionUInt32.read(from: &buf),
|
|||
|
|
children: FfiConverterSequenceUInt32.read(from: &buf),
|
|||
|
|
san: FfiConverterString.read(from: &buf),
|
|||
|
|
moveNumber: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
white: FfiConverterBool.read(from: &buf),
|
|||
|
|
nags: FfiConverterData.read(from: &buf),
|
|||
|
|
nagSymbols: FfiConverterString.read(from: &buf),
|
|||
|
|
commentBefore: FfiConverterString.read(from: &buf),
|
|||
|
|
commentAfter: FfiConverterString.read(from: &buf),
|
|||
|
|
fen: FfiConverterString.read(from: &buf),
|
|||
|
|
fromSquare: FfiConverterOptionString.read(from: &buf),
|
|||
|
|
toSquare: FfiConverterOptionString.read(from: &buf),
|
|||
|
|
nullMove: FfiConverterBool.read(from: &buf),
|
|||
|
|
uci: FfiConverterString.read(from: &buf),
|
|||
|
|
marks: FfiConverterSequenceTypeMark.read(from: &buf),
|
|||
|
|
end: FfiConverterString.read(from: &buf),
|
|||
|
|
mainLine: FfiConverterBool.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: MoveNode, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterUInt32.write(value.id, into: &buf)
|
|||
|
|
FfiConverterOptionUInt32.write(value.parent, into: &buf)
|
|||
|
|
FfiConverterSequenceUInt32.write(value.children, into: &buf)
|
|||
|
|
FfiConverterString.write(value.san, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.moveNumber, into: &buf)
|
|||
|
|
FfiConverterBool.write(value.white, into: &buf)
|
|||
|
|
FfiConverterData.write(value.nags, into: &buf)
|
|||
|
|
FfiConverterString.write(value.nagSymbols, into: &buf)
|
|||
|
|
FfiConverterString.write(value.commentBefore, into: &buf)
|
|||
|
|
FfiConverterString.write(value.commentAfter, into: &buf)
|
|||
|
|
FfiConverterString.write(value.fen, into: &buf)
|
|||
|
|
FfiConverterOptionString.write(value.fromSquare, into: &buf)
|
|||
|
|
FfiConverterOptionString.write(value.toSquare, into: &buf)
|
|||
|
|
FfiConverterBool.write(value.nullMove, into: &buf)
|
|||
|
|
FfiConverterString.write(value.uci, into: &buf)
|
|||
|
|
FfiConverterSequenceTypeMark.write(value.marks, into: &buf)
|
|||
|
|
FfiConverterString.write(value.end, into: &buf)
|
|||
|
|
FfiConverterBool.write(value.mainLine, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeMoveNode_lift(_ buf: RustBuffer) throws -> MoveNode {
|
|||
|
|
return try FfiConverterTypeMoveNode.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeMoveNode_lower(_ value: MoveNode) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeMoveNode.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* An account on a site.
|
|||
|
|
*/
|
|||
|
|
public struct OnlineAccount: Equatable, Hashable {
|
|||
|
|
public var site: Site
|
|||
|
|
/**
|
|||
|
|
* As the site spells it.
|
|||
|
|
*/
|
|||
|
|
public var username: String
|
|||
|
|
/**
|
|||
|
|
* Lichess: the games of the account (of all kinds, so at most this many).
|
|||
|
|
*/
|
|||
|
|
public var games: UInt64?
|
|||
|
|
/**
|
|||
|
|
* Chess.com: the months with games.
|
|||
|
|
*/
|
|||
|
|
public var months: UInt32?
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(site: Site,
|
|||
|
|
/**
|
|||
|
|
* As the site spells it.
|
|||
|
|
*/username: String,
|
|||
|
|
/**
|
|||
|
|
* Lichess: the games of the account (of all kinds, so at most this many).
|
|||
|
|
*/games: UInt64?,
|
|||
|
|
/**
|
|||
|
|
* Chess.com: the months with games.
|
|||
|
|
*/months: UInt32?) {
|
|||
|
|
self.site = site
|
|||
|
|
self.username = username
|
|||
|
|
self.games = games
|
|||
|
|
self.months = months
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension OnlineAccount: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeOnlineAccount: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OnlineAccount {
|
|||
|
|
return
|
|||
|
|
try OnlineAccount(
|
|||
|
|
site: FfiConverterTypeSite.read(from: &buf),
|
|||
|
|
username: FfiConverterString.read(from: &buf),
|
|||
|
|
games: FfiConverterOptionUInt64.read(from: &buf),
|
|||
|
|
months: FfiConverterOptionUInt32.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: OnlineAccount, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterTypeSite.write(value.site, into: &buf)
|
|||
|
|
FfiConverterString.write(value.username, into: &buf)
|
|||
|
|
FfiConverterOptionUInt64.write(value.games, into: &buf)
|
|||
|
|
FfiConverterOptionUInt32.write(value.months, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeOnlineAccount_lift(_ buf: RustBuffer) throws -> OnlineAccount {
|
|||
|
|
return try FfiConverterTypeOnlineAccount.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeOnlineAccount_lower(_ value: OnlineAccount) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeOnlineAccount.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* What a downloaded database holds.
|
|||
|
|
*/
|
|||
|
|
public struct OnlineDatabase: Equatable, Hashable {
|
|||
|
|
public var accounts: [OnlineAccount]
|
|||
|
|
/**
|
|||
|
|
* Games written into it.
|
|||
|
|
*/
|
|||
|
|
public var games: UInt64
|
|||
|
|
/**
|
|||
|
|
* When the last download finished (Unix seconds); none while it never finished.
|
|||
|
|
*/
|
|||
|
|
public var updated: Int64?
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(accounts: [OnlineAccount],
|
|||
|
|
/**
|
|||
|
|
* Games written into it.
|
|||
|
|
*/games: UInt64,
|
|||
|
|
/**
|
|||
|
|
* When the last download finished (Unix seconds); none while it never finished.
|
|||
|
|
*/updated: Int64?) {
|
|||
|
|
self.accounts = accounts
|
|||
|
|
self.games = games
|
|||
|
|
self.updated = updated
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension OnlineDatabase: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeOnlineDatabase: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OnlineDatabase {
|
|||
|
|
return
|
|||
|
|
try OnlineDatabase(
|
|||
|
|
accounts: FfiConverterSequenceTypeOnlineAccount.read(from: &buf),
|
|||
|
|
games: FfiConverterUInt64.read(from: &buf),
|
|||
|
|
updated: FfiConverterOptionInt64.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: OnlineDatabase, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterSequenceTypeOnlineAccount.write(value.accounts, into: &buf)
|
|||
|
|
FfiConverterUInt64.write(value.games, into: &buf)
|
|||
|
|
FfiConverterOptionInt64.write(value.updated, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeOnlineDatabase_lift(_ buf: RustBuffer) throws -> OnlineDatabase {
|
|||
|
|
return try FfiConverterTypeOnlineDatabase.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeOnlineDatabase_lower(_ value: OnlineDatabase) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeOnlineDatabase.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A problem, the site it came from (when known), and the technical text.
|
|||
|
|
*/
|
|||
|
|
public struct OnlineFailure: Equatable, Hashable {
|
|||
|
|
public var problem: OnlineProblem
|
|||
|
|
public var site: Site?
|
|||
|
|
public var detail: String
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(problem: OnlineProblem, site: Site?, detail: String) {
|
|||
|
|
self.problem = problem
|
|||
|
|
self.site = site
|
|||
|
|
self.detail = detail
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension OnlineFailure: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeOnlineFailure: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OnlineFailure {
|
|||
|
|
return
|
|||
|
|
try OnlineFailure(
|
|||
|
|
problem: FfiConverterTypeOnlineProblem.read(from: &buf),
|
|||
|
|
site: FfiConverterOptionTypeSite.read(from: &buf),
|
|||
|
|
detail: FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: OnlineFailure, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterTypeOnlineProblem.write(value.problem, into: &buf)
|
|||
|
|
FfiConverterOptionTypeSite.write(value.site, into: &buf)
|
|||
|
|
FfiConverterString.write(value.detail, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeOnlineFailure_lift(_ buf: RustBuffer) throws -> OnlineFailure {
|
|||
|
|
return try FfiConverterTypeOnlineFailure.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeOnlineFailure_lower(_ value: OnlineFailure) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeOnlineFailure.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Accounts and the database file they are downloaded into.
|
|||
|
|
*/
|
|||
|
|
public struct OnlineTarget: Equatable, Hashable {
|
|||
|
|
public var accounts: [OnlineAccount]
|
|||
|
|
public var path: String
|
|||
|
|
/**
|
|||
|
|
* The file is there already (its new games are fetched).
|
|||
|
|
*/
|
|||
|
|
public var exists: Bool
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(accounts: [OnlineAccount], path: String,
|
|||
|
|
/**
|
|||
|
|
* The file is there already (its new games are fetched).
|
|||
|
|
*/exists: Bool) {
|
|||
|
|
self.accounts = accounts
|
|||
|
|
self.path = path
|
|||
|
|
self.exists = exists
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension OnlineTarget: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeOnlineTarget: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OnlineTarget {
|
|||
|
|
return
|
|||
|
|
try OnlineTarget(
|
|||
|
|
accounts: FfiConverterSequenceTypeOnlineAccount.read(from: &buf),
|
|||
|
|
path: FfiConverterString.read(from: &buf),
|
|||
|
|
exists: FfiConverterBool.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: OnlineTarget, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterSequenceTypeOnlineAccount.write(value.accounts, into: &buf)
|
|||
|
|
FfiConverterString.write(value.path, into: &buf)
|
|||
|
|
FfiConverterBool.write(value.exists, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeOnlineTarget_lift(_ buf: RustBuffer) throws -> OnlineTarget {
|
|||
|
|
return try FfiConverterTypeOnlineTarget.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeOnlineTarget_lower(_ value: OnlineTarget) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeOnlineTarget.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* One exact player name from the database catalogue.
|
|||
|
|
*/
|
|||
|
|
public struct PlayerSuggestion: Equatable, Hashable {
|
|||
|
|
/**
|
|||
|
|
* Stable within this open database; used by [`Database::prepare_position`].
|
|||
|
|
*/
|
|||
|
|
public var id: UInt32
|
|||
|
|
public var name: String
|
|||
|
|
/**
|
|||
|
|
* Distinct games. A game with this name on both sides counts once here.
|
|||
|
|
*/
|
|||
|
|
public var games: UInt32
|
|||
|
|
public var whiteGames: UInt32
|
|||
|
|
public var blackGames: UInt32
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(
|
|||
|
|
/**
|
|||
|
|
* Stable within this open database; used by [`Database::prepare_position`].
|
|||
|
|
*/id: UInt32, name: String,
|
|||
|
|
/**
|
|||
|
|
* Distinct games. A game with this name on both sides counts once here.
|
|||
|
|
*/games: UInt32, whiteGames: UInt32, blackGames: UInt32) {
|
|||
|
|
self.id = id
|
|||
|
|
self.name = name
|
|||
|
|
self.games = games
|
|||
|
|
self.whiteGames = whiteGames
|
|||
|
|
self.blackGames = blackGames
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension PlayerSuggestion: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypePlayerSuggestion: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PlayerSuggestion {
|
|||
|
|
return
|
|||
|
|
try PlayerSuggestion(
|
|||
|
|
id: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
name: FfiConverterString.read(from: &buf),
|
|||
|
|
games: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
whiteGames: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
blackGames: FfiConverterUInt32.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: PlayerSuggestion, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterUInt32.write(value.id, into: &buf)
|
|||
|
|
FfiConverterString.write(value.name, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.games, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.whiteGames, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.blackGames, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePlayerSuggestion_lift(_ buf: RustBuffer) throws -> PlayerSuggestion {
|
|||
|
|
return try FfiConverterTypePlayerSuggestion.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePlayerSuggestion_lower(_ value: PlayerSuggestion) -> RustBuffer {
|
|||
|
|
return FfiConverterTypePlayerSuggestion.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A page of [`PlayerSuggestion`] and the total number of matching names.
|
|||
|
|
*/
|
|||
|
|
public struct PlayerSuggestions: Equatable, Hashable {
|
|||
|
|
public var players: [PlayerSuggestion]
|
|||
|
|
public var total: UInt32
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(players: [PlayerSuggestion], total: UInt32) {
|
|||
|
|
self.players = players
|
|||
|
|
self.total = total
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension PlayerSuggestions: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypePlayerSuggestions: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PlayerSuggestions {
|
|||
|
|
return
|
|||
|
|
try PlayerSuggestions(
|
|||
|
|
players: FfiConverterSequenceTypePlayerSuggestion.read(from: &buf),
|
|||
|
|
total: FfiConverterUInt32.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: PlayerSuggestions, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterSequenceTypePlayerSuggestion.write(value.players, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.total, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePlayerSuggestions_lift(_ buf: RustBuffer) throws -> PlayerSuggestions {
|
|||
|
|
return try FfiConverterTypePlayerSuggestions.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePlayerSuggestions_lower(_ value: PlayerSuggestions) -> RustBuffer {
|
|||
|
|
return FfiConverterTypePlayerSuggestions.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A move played next, with the selected player's results (not the mover's).
|
|||
|
|
*/
|
|||
|
|
public struct PrepContinuation: Equatable, Hashable {
|
|||
|
|
public var uci: String
|
|||
|
|
public var san: String
|
|||
|
|
public var count: UInt32
|
|||
|
|
public var wins: UInt32
|
|||
|
|
public var draws: UInt32
|
|||
|
|
public var losses: UInt32
|
|||
|
|
/**
|
|||
|
|
* Games with `Result "*"` (or another unknown result); not a loss.
|
|||
|
|
*/
|
|||
|
|
public var unknown: UInt32
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(uci: String, san: String, count: UInt32, wins: UInt32, draws: UInt32, losses: UInt32,
|
|||
|
|
/**
|
|||
|
|
* Games with `Result "*"` (or another unknown result); not a loss.
|
|||
|
|
*/unknown: UInt32) {
|
|||
|
|
self.uci = uci
|
|||
|
|
self.san = san
|
|||
|
|
self.count = count
|
|||
|
|
self.wins = wins
|
|||
|
|
self.draws = draws
|
|||
|
|
self.losses = losses
|
|||
|
|
self.unknown = unknown
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension PrepContinuation: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypePrepContinuation: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PrepContinuation {
|
|||
|
|
return
|
|||
|
|
try PrepContinuation(
|
|||
|
|
uci: FfiConverterString.read(from: &buf),
|
|||
|
|
san: FfiConverterString.read(from: &buf),
|
|||
|
|
count: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
wins: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
draws: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
losses: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
unknown: FfiConverterUInt32.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: PrepContinuation, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterString.write(value.uci, into: &buf)
|
|||
|
|
FfiConverterString.write(value.san, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.count, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.wins, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.draws, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.losses, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.unknown, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePrepContinuation_lift(_ buf: RustBuffer) throws -> PrepContinuation {
|
|||
|
|
return try FfiConverterTypePrepContinuation.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePrepContinuation_lower(_ value: PrepContinuation) -> RustBuffer {
|
|||
|
|
return FfiConverterTypePrepContinuation.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* One matching game. `ply` opens its first main-line occurrence of the position.
|
|||
|
|
*/
|
|||
|
|
public struct PrepMatch: Equatable, Hashable {
|
|||
|
|
public var index: UInt32
|
|||
|
|
public var ply: UInt32
|
|||
|
|
public var row: GameRow
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(index: UInt32, ply: UInt32, row: GameRow) {
|
|||
|
|
self.index = index
|
|||
|
|
self.ply = ply
|
|||
|
|
self.row = row
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension PrepMatch: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypePrepMatch: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PrepMatch {
|
|||
|
|
return
|
|||
|
|
try PrepMatch(
|
|||
|
|
index: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
ply: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
row: FfiConverterTypeGameRow.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: PrepMatch, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterUInt32.write(value.index, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.ply, into: &buf)
|
|||
|
|
FfiConverterTypeGameRow.write(value.row, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePrepMatch_lift(_ buf: RustBuffer) throws -> PrepMatch {
|
|||
|
|
return try FfiConverterTypePrepMatch.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePrepMatch_lower(_ value: PrepMatch) -> RustBuffer {
|
|||
|
|
return FfiConverterTypePrepMatch.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Continuations and results at one position.
|
|||
|
|
*/
|
|||
|
|
public struct PrepResult: Equatable, Hashable {
|
|||
|
|
/**
|
|||
|
|
* Matching games, each counted once at its first main-line occurrence.
|
|||
|
|
*/
|
|||
|
|
public var games: UInt32
|
|||
|
|
public var wins: UInt32
|
|||
|
|
public var draws: UInt32
|
|||
|
|
public var losses: UInt32
|
|||
|
|
public var unknown: UInt32
|
|||
|
|
/**
|
|||
|
|
* Whether the selected player (rather than their opponents) moves here.
|
|||
|
|
*/
|
|||
|
|
public var playerToMove: Bool
|
|||
|
|
/**
|
|||
|
|
* By count descending, then SAN ascending.
|
|||
|
|
*/
|
|||
|
|
public var continuations: [PrepContinuation]
|
|||
|
|
public var ended: UInt32
|
|||
|
|
/**
|
|||
|
|
* A teaching null move or a continuation that is not a normal legal move.
|
|||
|
|
*/
|
|||
|
|
public var noNormalContinuation: UInt32
|
|||
|
|
/**
|
|||
|
|
* At most 100 rows in record order; `matches_total` is the unpaginated count.
|
|||
|
|
*/
|
|||
|
|
public var matches: [PrepMatch]
|
|||
|
|
public var matchesTotal: UInt32
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(
|
|||
|
|
/**
|
|||
|
|
* Matching games, each counted once at its first main-line occurrence.
|
|||
|
|
*/games: UInt32, wins: UInt32, draws: UInt32, losses: UInt32, unknown: UInt32,
|
|||
|
|
/**
|
|||
|
|
* Whether the selected player (rather than their opponents) moves here.
|
|||
|
|
*/playerToMove: Bool,
|
|||
|
|
/**
|
|||
|
|
* By count descending, then SAN ascending.
|
|||
|
|
*/continuations: [PrepContinuation], ended: UInt32,
|
|||
|
|
/**
|
|||
|
|
* A teaching null move or a continuation that is not a normal legal move.
|
|||
|
|
*/noNormalContinuation: UInt32,
|
|||
|
|
/**
|
|||
|
|
* At most 100 rows in record order; `matches_total` is the unpaginated count.
|
|||
|
|
*/matches: [PrepMatch], matchesTotal: UInt32) {
|
|||
|
|
self.games = games
|
|||
|
|
self.wins = wins
|
|||
|
|
self.draws = draws
|
|||
|
|
self.losses = losses
|
|||
|
|
self.unknown = unknown
|
|||
|
|
self.playerToMove = playerToMove
|
|||
|
|
self.continuations = continuations
|
|||
|
|
self.ended = ended
|
|||
|
|
self.noNormalContinuation = noNormalContinuation
|
|||
|
|
self.matches = matches
|
|||
|
|
self.matchesTotal = matchesTotal
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension PrepResult: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypePrepResult: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PrepResult {
|
|||
|
|
return
|
|||
|
|
try PrepResult(
|
|||
|
|
games: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
wins: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
draws: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
losses: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
unknown: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
playerToMove: FfiConverterBool.read(from: &buf),
|
|||
|
|
continuations: FfiConverterSequenceTypePrepContinuation.read(from: &buf),
|
|||
|
|
ended: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
noNormalContinuation: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
matches: FfiConverterSequenceTypePrepMatch.read(from: &buf),
|
|||
|
|
matchesTotal: FfiConverterUInt32.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: PrepResult, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterUInt32.write(value.games, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.wins, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.draws, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.losses, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.unknown, into: &buf)
|
|||
|
|
FfiConverterBool.write(value.playerToMove, into: &buf)
|
|||
|
|
FfiConverterSequenceTypePrepContinuation.write(value.continuations, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.ended, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.noNormalContinuation, into: &buf)
|
|||
|
|
FfiConverterSequenceTypePrepMatch.write(value.matches, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.matchesTotal, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePrepResult_lift(_ buf: RustBuffer) throws -> PrepResult {
|
|||
|
|
return try FfiConverterTypePrepResult.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePrepResult_lower(_ value: PrepResult) -> RustBuffer {
|
|||
|
|
return FfiConverterTypePrepResult.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A snapshot of a preparation worker.
|
|||
|
|
*/
|
|||
|
|
public struct PrepState: Equatable, Hashable {
|
|||
|
|
public var phase: PrepPhase
|
|||
|
|
/**
|
|||
|
|
* Progress inside the current phase (`total == 0` means not applicable).
|
|||
|
|
*/
|
|||
|
|
public var done: UInt32
|
|||
|
|
public var total: UInt32
|
|||
|
|
public var running: Bool
|
|||
|
|
public var result: PrepResult?
|
|||
|
|
/**
|
|||
|
|
* Empty except for `Failed` and `NoMemory`.
|
|||
|
|
*/
|
|||
|
|
public var failure: String
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(phase: PrepPhase,
|
|||
|
|
/**
|
|||
|
|
* Progress inside the current phase (`total == 0` means not applicable).
|
|||
|
|
*/done: UInt32, total: UInt32, running: Bool, result: PrepResult?,
|
|||
|
|
/**
|
|||
|
|
* Empty except for `Failed` and `NoMemory`.
|
|||
|
|
*/failure: String) {
|
|||
|
|
self.phase = phase
|
|||
|
|
self.done = done
|
|||
|
|
self.total = total
|
|||
|
|
self.running = running
|
|||
|
|
self.result = result
|
|||
|
|
self.failure = failure
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension PrepState: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypePrepState: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PrepState {
|
|||
|
|
return
|
|||
|
|
try PrepState(
|
|||
|
|
phase: FfiConverterTypePrepPhase.read(from: &buf),
|
|||
|
|
done: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
total: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
running: FfiConverterBool.read(from: &buf),
|
|||
|
|
result: FfiConverterOptionTypePrepResult.read(from: &buf),
|
|||
|
|
failure: FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: PrepState, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterTypePrepPhase.write(value.phase, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.done, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.total, into: &buf)
|
|||
|
|
FfiConverterBool.write(value.running, into: &buf)
|
|||
|
|
FfiConverterOptionTypePrepResult.write(value.result, into: &buf)
|
|||
|
|
FfiConverterString.write(value.failure, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePrepState_lift(_ buf: RustBuffer) throws -> PrepState {
|
|||
|
|
return try FfiConverterTypePrepState.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePrepState_lower(_ value: PrepState) -> RustBuffer {
|
|||
|
|
return FfiConverterTypePrepState.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A marked move of the main line: an inaccuracy, mistake or blunder, or a great or
|
|||
|
|
* brilliant move (these have no better line and no reply).
|
|||
|
|
*/
|
|||
|
|
public struct ReviewMove: Equatable, Hashable {
|
|||
|
|
/**
|
|||
|
|
* The node of the move.
|
|||
|
|
*/
|
|||
|
|
public var node: UInt32
|
|||
|
|
public var judgement: MoveJudgement
|
|||
|
|
/**
|
|||
|
|
* White made the move.
|
|||
|
|
*/
|
|||
|
|
public var white: Bool
|
|||
|
|
/**
|
|||
|
|
* The engine's line from the position before the move (its first move was
|
|||
|
|
* better), to show on the board; `None` when the evaluation came from the PGN.
|
|||
|
|
*/
|
|||
|
|
public var best: EngineLine?
|
|||
|
|
/**
|
|||
|
|
* The better move with its number, Latin letters: "23…Nf6" ("" when unknown).
|
|||
|
|
*/
|
|||
|
|
public var bestLabel: String
|
|||
|
|
/**
|
|||
|
|
* How the opponent punishes the move: the engine's reply, for an arrow.
|
|||
|
|
*/
|
|||
|
|
public var replyFrom: String?
|
|||
|
|
public var replyTo: String?
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(
|
|||
|
|
/**
|
|||
|
|
* The node of the move.
|
|||
|
|
*/node: UInt32, judgement: MoveJudgement,
|
|||
|
|
/**
|
|||
|
|
* White made the move.
|
|||
|
|
*/white: Bool,
|
|||
|
|
/**
|
|||
|
|
* The engine's line from the position before the move (its first move was
|
|||
|
|
* better), to show on the board; `None` when the evaluation came from the PGN.
|
|||
|
|
*/best: EngineLine?,
|
|||
|
|
/**
|
|||
|
|
* The better move with its number, Latin letters: "23…Nf6" ("" when unknown).
|
|||
|
|
*/bestLabel: String,
|
|||
|
|
/**
|
|||
|
|
* How the opponent punishes the move: the engine's reply, for an arrow.
|
|||
|
|
*/replyFrom: String?, replyTo: String?) {
|
|||
|
|
self.node = node
|
|||
|
|
self.judgement = judgement
|
|||
|
|
self.white = white
|
|||
|
|
self.best = best
|
|||
|
|
self.bestLabel = bestLabel
|
|||
|
|
self.replyFrom = replyFrom
|
|||
|
|
self.replyTo = replyTo
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension ReviewMove: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeReviewMove: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ReviewMove {
|
|||
|
|
return
|
|||
|
|
try ReviewMove(
|
|||
|
|
node: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
judgement: FfiConverterTypeMoveJudgement.read(from: &buf),
|
|||
|
|
white: FfiConverterBool.read(from: &buf),
|
|||
|
|
best: FfiConverterOptionTypeEngineLine.read(from: &buf),
|
|||
|
|
bestLabel: FfiConverterString.read(from: &buf),
|
|||
|
|
replyFrom: FfiConverterOptionString.read(from: &buf),
|
|||
|
|
replyTo: FfiConverterOptionString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: ReviewMove, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterUInt32.write(value.node, into: &buf)
|
|||
|
|
FfiConverterTypeMoveJudgement.write(value.judgement, into: &buf)
|
|||
|
|
FfiConverterBool.write(value.white, into: &buf)
|
|||
|
|
FfiConverterOptionTypeEngineLine.write(value.best, into: &buf)
|
|||
|
|
FfiConverterString.write(value.bestLabel, into: &buf)
|
|||
|
|
FfiConverterOptionString.write(value.replyFrom, into: &buf)
|
|||
|
|
FfiConverterOptionString.write(value.replyTo, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeReviewMove_lift(_ buf: RustBuffer) throws -> ReviewMove {
|
|||
|
|
return try FfiConverterTypeReviewMove.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeReviewMove_lower(_ value: ReviewMove) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeReviewMove.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A position of the main line: the start, then the one after each move.
|
|||
|
|
*/
|
|||
|
|
public struct ReviewPoint: Equatable, Hashable {
|
|||
|
|
/**
|
|||
|
|
* The node (of [`crate::GameData`]) of this position.
|
|||
|
|
*/
|
|||
|
|
public var node: UInt32
|
|||
|
|
/**
|
|||
|
|
* White's chance of winning, 0..100, when the position is evaluated.
|
|||
|
|
*/
|
|||
|
|
public var whiteWin: Float?
|
|||
|
|
/**
|
|||
|
|
* "+0.35", "−1.20", "#3", "#−2", "1-0" ("" while not evaluated).
|
|||
|
|
*/
|
|||
|
|
public var eval: String
|
|||
|
|
/**
|
|||
|
|
* The judgement of the move that led here.
|
|||
|
|
*/
|
|||
|
|
public var judgement: MoveJudgement?
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(
|
|||
|
|
/**
|
|||
|
|
* The node (of [`crate::GameData`]) of this position.
|
|||
|
|
*/node: UInt32,
|
|||
|
|
/**
|
|||
|
|
* White's chance of winning, 0..100, when the position is evaluated.
|
|||
|
|
*/whiteWin: Float?,
|
|||
|
|
/**
|
|||
|
|
* "+0.35", "−1.20", "#3", "#−2", "1-0" ("" while not evaluated).
|
|||
|
|
*/eval: String,
|
|||
|
|
/**
|
|||
|
|
* The judgement of the move that led here.
|
|||
|
|
*/judgement: MoveJudgement?) {
|
|||
|
|
self.node = node
|
|||
|
|
self.whiteWin = whiteWin
|
|||
|
|
self.eval = eval
|
|||
|
|
self.judgement = judgement
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension ReviewPoint: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeReviewPoint: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ReviewPoint {
|
|||
|
|
return
|
|||
|
|
try ReviewPoint(
|
|||
|
|
node: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
whiteWin: FfiConverterOptionFloat.read(from: &buf),
|
|||
|
|
eval: FfiConverterString.read(from: &buf),
|
|||
|
|
judgement: FfiConverterOptionTypeMoveJudgement.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: ReviewPoint, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterUInt32.write(value.node, into: &buf)
|
|||
|
|
FfiConverterOptionFloat.write(value.whiteWin, into: &buf)
|
|||
|
|
FfiConverterString.write(value.eval, into: &buf)
|
|||
|
|
FfiConverterOptionTypeMoveJudgement.write(value.judgement, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeReviewPoint_lift(_ buf: RustBuffer) throws -> ReviewPoint {
|
|||
|
|
return try FfiConverterTypeReviewPoint.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeReviewPoint_lower(_ value: ReviewPoint) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeReviewPoint.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Everything about the analysis of the game at this moment.
|
|||
|
|
*/
|
|||
|
|
public struct ReviewState: Equatable, Hashable {
|
|||
|
|
/**
|
|||
|
|
* The engine job is running.
|
|||
|
|
*/
|
|||
|
|
public var running: Bool
|
|||
|
|
/**
|
|||
|
|
* Positions evaluated by this run, of `total`.
|
|||
|
|
*/
|
|||
|
|
public var done: UInt32
|
|||
|
|
public var total: UInt32
|
|||
|
|
/**
|
|||
|
|
* Why the last run stopped early (the engine crashed, did not start).
|
|||
|
|
*/
|
|||
|
|
public var failure: String?
|
|||
|
|
/**
|
|||
|
|
* Some evaluations exist (from the engine, the cache or the PGN).
|
|||
|
|
*/
|
|||
|
|
public var hasData: Bool
|
|||
|
|
/**
|
|||
|
|
* The engine's name; "PGN" when the evaluations come from `[%eval]` comments.
|
|||
|
|
*/
|
|||
|
|
public var engine: String
|
|||
|
|
/**
|
|||
|
|
* Nodes per position; 0 for evaluations from the PGN.
|
|||
|
|
*/
|
|||
|
|
public var nodes: UInt64
|
|||
|
|
/**
|
|||
|
|
* The evaluations come from another engine search than today's fixed one (an
|
|||
|
|
* analysis made before it): shown, but "update" makes them all again.
|
|||
|
|
*/
|
|||
|
|
public var stale: Bool
|
|||
|
|
/**
|
|||
|
|
* Positions of the main line without an evaluation.
|
|||
|
|
*/
|
|||
|
|
public var missing: UInt32
|
|||
|
|
/**
|
|||
|
|
* Evaluated positions still waiting for the second search of !! and ! (an analysis
|
|||
|
|
* from before them): "fill in" does it.
|
|||
|
|
*/
|
|||
|
|
public var secondsMissing: UInt32
|
|||
|
|
/**
|
|||
|
|
* Positions a full analysis looks at (for the time estimate).
|
|||
|
|
*/
|
|||
|
|
public var positions: UInt32
|
|||
|
|
/**
|
|||
|
|
* Engine searches a full analysis is expected to make (for the time estimate: a
|
|||
|
|
* second search for moves that could be brilliant or great).
|
|||
|
|
*/
|
|||
|
|
public var searches: UInt32
|
|||
|
|
/**
|
|||
|
|
* The speed of one engine process in the last run (0 when unknown).
|
|||
|
|
*/
|
|||
|
|
public var npsPerProcess: UInt64
|
|||
|
|
/**
|
|||
|
|
* The start position and the position after every main-line move.
|
|||
|
|
*/
|
|||
|
|
public var points: [ReviewPoint]
|
|||
|
|
/**
|
|||
|
|
* Where the middlegame and the endgame begin, as indices of `points`.
|
|||
|
|
*/
|
|||
|
|
public var middlegame: UInt32?
|
|||
|
|
public var endgame: UInt32?
|
|||
|
|
public var white: SideReview
|
|||
|
|
public var black: SideReview
|
|||
|
|
/**
|
|||
|
|
* The marked moves, in the order of the game.
|
|||
|
|
*/
|
|||
|
|
public var moves: [ReviewMove]
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(
|
|||
|
|
/**
|
|||
|
|
* The engine job is running.
|
|||
|
|
*/running: Bool,
|
|||
|
|
/**
|
|||
|
|
* Positions evaluated by this run, of `total`.
|
|||
|
|
*/done: UInt32, total: UInt32,
|
|||
|
|
/**
|
|||
|
|
* Why the last run stopped early (the engine crashed, did not start).
|
|||
|
|
*/failure: String?,
|
|||
|
|
/**
|
|||
|
|
* Some evaluations exist (from the engine, the cache or the PGN).
|
|||
|
|
*/hasData: Bool,
|
|||
|
|
/**
|
|||
|
|
* The engine's name; "PGN" when the evaluations come from `[%eval]` comments.
|
|||
|
|
*/engine: String,
|
|||
|
|
/**
|
|||
|
|
* Nodes per position; 0 for evaluations from the PGN.
|
|||
|
|
*/nodes: UInt64,
|
|||
|
|
/**
|
|||
|
|
* The evaluations come from another engine search than today's fixed one (an
|
|||
|
|
* analysis made before it): shown, but "update" makes them all again.
|
|||
|
|
*/stale: Bool,
|
|||
|
|
/**
|
|||
|
|
* Positions of the main line without an evaluation.
|
|||
|
|
*/missing: UInt32,
|
|||
|
|
/**
|
|||
|
|
* Evaluated positions still waiting for the second search of !! and ! (an analysis
|
|||
|
|
* from before them): "fill in" does it.
|
|||
|
|
*/secondsMissing: UInt32,
|
|||
|
|
/**
|
|||
|
|
* Positions a full analysis looks at (for the time estimate).
|
|||
|
|
*/positions: UInt32,
|
|||
|
|
/**
|
|||
|
|
* Engine searches a full analysis is expected to make (for the time estimate: a
|
|||
|
|
* second search for moves that could be brilliant or great).
|
|||
|
|
*/searches: UInt32,
|
|||
|
|
/**
|
|||
|
|
* The speed of one engine process in the last run (0 when unknown).
|
|||
|
|
*/npsPerProcess: UInt64,
|
|||
|
|
/**
|
|||
|
|
* The start position and the position after every main-line move.
|
|||
|
|
*/points: [ReviewPoint],
|
|||
|
|
/**
|
|||
|
|
* Where the middlegame and the endgame begin, as indices of `points`.
|
|||
|
|
*/middlegame: UInt32?, endgame: UInt32?, white: SideReview, black: SideReview,
|
|||
|
|
/**
|
|||
|
|
* The marked moves, in the order of the game.
|
|||
|
|
*/moves: [ReviewMove]) {
|
|||
|
|
self.running = running
|
|||
|
|
self.done = done
|
|||
|
|
self.total = total
|
|||
|
|
self.failure = failure
|
|||
|
|
self.hasData = hasData
|
|||
|
|
self.engine = engine
|
|||
|
|
self.nodes = nodes
|
|||
|
|
self.stale = stale
|
|||
|
|
self.missing = missing
|
|||
|
|
self.secondsMissing = secondsMissing
|
|||
|
|
self.positions = positions
|
|||
|
|
self.searches = searches
|
|||
|
|
self.npsPerProcess = npsPerProcess
|
|||
|
|
self.points = points
|
|||
|
|
self.middlegame = middlegame
|
|||
|
|
self.endgame = endgame
|
|||
|
|
self.white = white
|
|||
|
|
self.black = black
|
|||
|
|
self.moves = moves
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension ReviewState: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeReviewState: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ReviewState {
|
|||
|
|
return
|
|||
|
|
try ReviewState(
|
|||
|
|
running: FfiConverterBool.read(from: &buf),
|
|||
|
|
done: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
total: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
failure: FfiConverterOptionString.read(from: &buf),
|
|||
|
|
hasData: FfiConverterBool.read(from: &buf),
|
|||
|
|
engine: FfiConverterString.read(from: &buf),
|
|||
|
|
nodes: FfiConverterUInt64.read(from: &buf),
|
|||
|
|
stale: FfiConverterBool.read(from: &buf),
|
|||
|
|
missing: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
secondsMissing: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
positions: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
searches: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
npsPerProcess: FfiConverterUInt64.read(from: &buf),
|
|||
|
|
points: FfiConverterSequenceTypeReviewPoint.read(from: &buf),
|
|||
|
|
middlegame: FfiConverterOptionUInt32.read(from: &buf),
|
|||
|
|
endgame: FfiConverterOptionUInt32.read(from: &buf),
|
|||
|
|
white: FfiConverterTypeSideReview.read(from: &buf),
|
|||
|
|
black: FfiConverterTypeSideReview.read(from: &buf),
|
|||
|
|
moves: FfiConverterSequenceTypeReviewMove.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: ReviewState, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterBool.write(value.running, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.done, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.total, into: &buf)
|
|||
|
|
FfiConverterOptionString.write(value.failure, into: &buf)
|
|||
|
|
FfiConverterBool.write(value.hasData, into: &buf)
|
|||
|
|
FfiConverterString.write(value.engine, into: &buf)
|
|||
|
|
FfiConverterUInt64.write(value.nodes, into: &buf)
|
|||
|
|
FfiConverterBool.write(value.stale, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.missing, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.secondsMissing, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.positions, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.searches, into: &buf)
|
|||
|
|
FfiConverterUInt64.write(value.npsPerProcess, into: &buf)
|
|||
|
|
FfiConverterSequenceTypeReviewPoint.write(value.points, into: &buf)
|
|||
|
|
FfiConverterOptionUInt32.write(value.middlegame, into: &buf)
|
|||
|
|
FfiConverterOptionUInt32.write(value.endgame, into: &buf)
|
|||
|
|
FfiConverterTypeSideReview.write(value.white, into: &buf)
|
|||
|
|
FfiConverterTypeSideReview.write(value.black, into: &buf)
|
|||
|
|
FfiConverterSequenceTypeReviewMove.write(value.moves, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeReviewState_lift(_ buf: RustBuffer) throws -> ReviewState {
|
|||
|
|
return try FfiConverterTypeReviewState.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeReviewState_lower(_ value: ReviewState) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeReviewState.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A file of the book pack: where it comes from, where it goes (under the engine's
|
|||
|
|
* home), its size and SHA-256.
|
|||
|
|
*/
|
|||
|
|
public struct RodentBook: Equatable, Hashable {
|
|||
|
|
public var url: String
|
|||
|
|
public var local: String
|
|||
|
|
public var size: UInt64
|
|||
|
|
public var sha256: String
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(url: String, local: String, size: UInt64, sha256: String) {
|
|||
|
|
self.url = url
|
|||
|
|
self.local = local
|
|||
|
|
self.size = size
|
|||
|
|
self.sha256 = sha256
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension RodentBook: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeRodentBook: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RodentBook {
|
|||
|
|
return
|
|||
|
|
try RodentBook(
|
|||
|
|
url: FfiConverterString.read(from: &buf),
|
|||
|
|
local: FfiConverterString.read(from: &buf),
|
|||
|
|
size: FfiConverterUInt64.read(from: &buf),
|
|||
|
|
sha256: FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: RodentBook, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterString.write(value.url, into: &buf)
|
|||
|
|
FfiConverterString.write(value.local, into: &buf)
|
|||
|
|
FfiConverterUInt64.write(value.size, into: &buf)
|
|||
|
|
FfiConverterString.write(value.sha256, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeRodentBook_lift(_ buf: RustBuffer) throws -> RodentBook {
|
|||
|
|
return try FfiConverterTypeRodentBook.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeRodentBook_lower(_ value: RodentBook) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeRodentBook.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A character of Rodent IV: its id, its English name (for PGN), its title and what it
|
|||
|
|
* does (English: the app shows its own translations), a great player or not.
|
|||
|
|
*/
|
|||
|
|
public struct RodentStyle: Equatable, Hashable {
|
|||
|
|
public var id: String
|
|||
|
|
public var name: String
|
|||
|
|
public var title: String
|
|||
|
|
public var about: String
|
|||
|
|
public var player: Bool
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(id: String, name: String, title: String, about: String, player: Bool) {
|
|||
|
|
self.id = id
|
|||
|
|
self.name = name
|
|||
|
|
self.title = title
|
|||
|
|
self.about = about
|
|||
|
|
self.player = player
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension RodentStyle: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeRodentStyle: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RodentStyle {
|
|||
|
|
return
|
|||
|
|
try RodentStyle(
|
|||
|
|
id: FfiConverterString.read(from: &buf),
|
|||
|
|
name: FfiConverterString.read(from: &buf),
|
|||
|
|
title: FfiConverterString.read(from: &buf),
|
|||
|
|
about: FfiConverterString.read(from: &buf),
|
|||
|
|
player: FfiConverterBool.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: RodentStyle, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterString.write(value.id, into: &buf)
|
|||
|
|
FfiConverterString.write(value.name, into: &buf)
|
|||
|
|
FfiConverterString.write(value.title, into: &buf)
|
|||
|
|
FfiConverterString.write(value.about, into: &buf)
|
|||
|
|
FfiConverterBool.write(value.player, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeRodentStyle_lift(_ buf: RustBuffer) throws -> RodentStyle {
|
|||
|
|
return try FfiConverterTypeRodentStyle.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeRodentStyle_lower(_ value: RodentStyle) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeRodentStyle.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* One player's numbers.
|
|||
|
|
*/
|
|||
|
|
public struct SideReview: Equatable, Hashable {
|
|||
|
|
public var inaccuracies: UInt32
|
|||
|
|
public var mistakes: UInt32
|
|||
|
|
public var blunders: UInt32
|
|||
|
|
public var great: UInt32
|
|||
|
|
public var brilliant: UInt32
|
|||
|
|
/**
|
|||
|
|
* Average centipawn loss.
|
|||
|
|
*/
|
|||
|
|
public var acpl: UInt32?
|
|||
|
|
/**
|
|||
|
|
* Accuracy 0..100 (only when every position is evaluated).
|
|||
|
|
*/
|
|||
|
|
public var accuracy: Double?
|
|||
|
|
public var opening: Double?
|
|||
|
|
public var middlegame: Double?
|
|||
|
|
public var endgame: Double?
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(inaccuracies: UInt32, mistakes: UInt32, blunders: UInt32, great: UInt32, brilliant: UInt32,
|
|||
|
|
/**
|
|||
|
|
* Average centipawn loss.
|
|||
|
|
*/acpl: UInt32?,
|
|||
|
|
/**
|
|||
|
|
* Accuracy 0..100 (only when every position is evaluated).
|
|||
|
|
*/accuracy: Double?, opening: Double?, middlegame: Double?, endgame: Double?) {
|
|||
|
|
self.inaccuracies = inaccuracies
|
|||
|
|
self.mistakes = mistakes
|
|||
|
|
self.blunders = blunders
|
|||
|
|
self.great = great
|
|||
|
|
self.brilliant = brilliant
|
|||
|
|
self.acpl = acpl
|
|||
|
|
self.accuracy = accuracy
|
|||
|
|
self.opening = opening
|
|||
|
|
self.middlegame = middlegame
|
|||
|
|
self.endgame = endgame
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension SideReview: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeSideReview: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SideReview {
|
|||
|
|
return
|
|||
|
|
try SideReview(
|
|||
|
|
inaccuracies: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
mistakes: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
blunders: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
great: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
brilliant: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
acpl: FfiConverterOptionUInt32.read(from: &buf),
|
|||
|
|
accuracy: FfiConverterOptionDouble.read(from: &buf),
|
|||
|
|
opening: FfiConverterOptionDouble.read(from: &buf),
|
|||
|
|
middlegame: FfiConverterOptionDouble.read(from: &buf),
|
|||
|
|
endgame: FfiConverterOptionDouble.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: SideReview, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterUInt32.write(value.inaccuracies, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.mistakes, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.blunders, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.great, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.brilliant, into: &buf)
|
|||
|
|
FfiConverterOptionUInt32.write(value.acpl, into: &buf)
|
|||
|
|
FfiConverterOptionDouble.write(value.accuracy, into: &buf)
|
|||
|
|
FfiConverterOptionDouble.write(value.opening, into: &buf)
|
|||
|
|
FfiConverterOptionDouble.write(value.middlegame, into: &buf)
|
|||
|
|
FfiConverterOptionDouble.write(value.endgame, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeSideReview_lift(_ buf: RustBuffer) throws -> SideReview {
|
|||
|
|
return try FfiConverterTypeSideReview.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeSideReview_lower(_ value: SideReview) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeSideReview.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A PGN tag.
|
|||
|
|
*/
|
|||
|
|
public struct Tag: Equatable, Hashable {
|
|||
|
|
public var name: String
|
|||
|
|
public var value: String
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(name: String, value: String) {
|
|||
|
|
self.name = name
|
|||
|
|
self.value = value
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension Tag: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeTag: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Tag {
|
|||
|
|
return
|
|||
|
|
try Tag(
|
|||
|
|
name: FfiConverterString.read(from: &buf),
|
|||
|
|
value: FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: Tag, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterString.write(value.name, into: &buf)
|
|||
|
|
FfiConverterString.write(value.value, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeTag_lift(_ buf: RustBuffer) throws -> Tag {
|
|||
|
|
return try FfiConverterTypeTag.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeTag_lower(_ value: Tag) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeTag.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The state of the run after `ply` half-moves.
|
|||
|
|
*/
|
|||
|
|
public struct TrainState: Equatable, Hashable {
|
|||
|
|
/**
|
|||
|
|
* The position now, and the move that led here (none at the start).
|
|||
|
|
*/
|
|||
|
|
public var fen: String
|
|||
|
|
public var fromSquare: String?
|
|||
|
|
public var toSquare: String?
|
|||
|
|
/**
|
|||
|
|
* The moves played so far, in SAN (Latin letters).
|
|||
|
|
*/
|
|||
|
|
public var played: [String]
|
|||
|
|
/**
|
|||
|
|
* Half-moves in the line.
|
|||
|
|
*/
|
|||
|
|
public var length: UInt32
|
|||
|
|
public var mistakesHere: UInt32
|
|||
|
|
public var mistakes: UInt32
|
|||
|
|
/**
|
|||
|
|
* The user may ask to see this move; it is shown now (from, to).
|
|||
|
|
*/
|
|||
|
|
public var mayShow: Bool
|
|||
|
|
public var hint: [String]?
|
|||
|
|
public var hinted: Bool
|
|||
|
|
public var done: Bool
|
|||
|
|
public var before: TrainStats
|
|||
|
|
public var after: TrainStats?
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(
|
|||
|
|
/**
|
|||
|
|
* The position now, and the move that led here (none at the start).
|
|||
|
|
*/fen: String, fromSquare: String?, toSquare: String?,
|
|||
|
|
/**
|
|||
|
|
* The moves played so far, in SAN (Latin letters).
|
|||
|
|
*/played: [String],
|
|||
|
|
/**
|
|||
|
|
* Half-moves in the line.
|
|||
|
|
*/length: UInt32, mistakesHere: UInt32, mistakes: UInt32,
|
|||
|
|
/**
|
|||
|
|
* The user may ask to see this move; it is shown now (from, to).
|
|||
|
|
*/mayShow: Bool, hint: [String]?, hinted: Bool, done: Bool, before: TrainStats, after: TrainStats?) {
|
|||
|
|
self.fen = fen
|
|||
|
|
self.fromSquare = fromSquare
|
|||
|
|
self.toSquare = toSquare
|
|||
|
|
self.played = played
|
|||
|
|
self.length = length
|
|||
|
|
self.mistakesHere = mistakesHere
|
|||
|
|
self.mistakes = mistakes
|
|||
|
|
self.mayShow = mayShow
|
|||
|
|
self.hint = hint
|
|||
|
|
self.hinted = hinted
|
|||
|
|
self.done = done
|
|||
|
|
self.before = before
|
|||
|
|
self.after = after
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension TrainState: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeTrainState: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrainState {
|
|||
|
|
return
|
|||
|
|
try TrainState(
|
|||
|
|
fen: FfiConverterString.read(from: &buf),
|
|||
|
|
fromSquare: FfiConverterOptionString.read(from: &buf),
|
|||
|
|
toSquare: FfiConverterOptionString.read(from: &buf),
|
|||
|
|
played: FfiConverterSequenceString.read(from: &buf),
|
|||
|
|
length: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
mistakesHere: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
mistakes: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
mayShow: FfiConverterBool.read(from: &buf),
|
|||
|
|
hint: FfiConverterOptionSequenceString.read(from: &buf),
|
|||
|
|
hinted: FfiConverterBool.read(from: &buf),
|
|||
|
|
done: FfiConverterBool.read(from: &buf),
|
|||
|
|
before: FfiConverterTypeTrainStats.read(from: &buf),
|
|||
|
|
after: FfiConverterOptionTypeTrainStats.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: TrainState, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterString.write(value.fen, into: &buf)
|
|||
|
|
FfiConverterOptionString.write(value.fromSquare, into: &buf)
|
|||
|
|
FfiConverterOptionString.write(value.toSquare, into: &buf)
|
|||
|
|
FfiConverterSequenceString.write(value.played, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.length, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.mistakesHere, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.mistakes, into: &buf)
|
|||
|
|
FfiConverterBool.write(value.mayShow, into: &buf)
|
|||
|
|
FfiConverterOptionSequenceString.write(value.hint, into: &buf)
|
|||
|
|
FfiConverterBool.write(value.hinted, into: &buf)
|
|||
|
|
FfiConverterBool.write(value.done, into: &buf)
|
|||
|
|
FfiConverterTypeTrainStats.write(value.before, into: &buf)
|
|||
|
|
FfiConverterOptionTypeTrainStats.write(value.after, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeTrainState_lift(_ buf: RustBuffer) throws -> TrainState {
|
|||
|
|
return try FfiConverterTypeTrainState.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeTrainState_lower(_ value: TrainState) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeTrainState.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The runs of a line so far.
|
|||
|
|
*/
|
|||
|
|
public struct TrainStats: Equatable, Hashable {
|
|||
|
|
public var runs: UInt32
|
|||
|
|
public var last: UInt32?
|
|||
|
|
public var best: UInt32?
|
|||
|
|
public var cleanStreak: UInt32
|
|||
|
|
/**
|
|||
|
|
* The last runs, oldest first: their mistakes and whether the move was shown.
|
|||
|
|
*/
|
|||
|
|
public var recentMistakes: [UInt32]
|
|||
|
|
public var recentHinted: [Bool]
|
|||
|
|
|
|||
|
|
// Default memberwise initializers are never public by default, so we
|
|||
|
|
// declare one manually.
|
|||
|
|
public init(runs: UInt32, last: UInt32?, best: UInt32?, cleanStreak: UInt32,
|
|||
|
|
/**
|
|||
|
|
* The last runs, oldest first: their mistakes and whether the move was shown.
|
|||
|
|
*/recentMistakes: [UInt32], recentHinted: [Bool]) {
|
|||
|
|
self.runs = runs
|
|||
|
|
self.last = last
|
|||
|
|
self.best = best
|
|||
|
|
self.cleanStreak = cleanStreak
|
|||
|
|
self.recentMistakes = recentMistakes
|
|||
|
|
self.recentHinted = recentHinted
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension TrainStats: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeTrainStats: FfiConverterRustBuffer {
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrainStats {
|
|||
|
|
return
|
|||
|
|
try TrainStats(
|
|||
|
|
runs: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
last: FfiConverterOptionUInt32.read(from: &buf),
|
|||
|
|
best: FfiConverterOptionUInt32.read(from: &buf),
|
|||
|
|
cleanStreak: FfiConverterUInt32.read(from: &buf),
|
|||
|
|
recentMistakes: FfiConverterSequenceUInt32.read(from: &buf),
|
|||
|
|
recentHinted: FfiConverterSequenceBool.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: TrainStats, into buf: inout [UInt8]) {
|
|||
|
|
FfiConverterUInt32.write(value.runs, into: &buf)
|
|||
|
|
FfiConverterOptionUInt32.write(value.last, into: &buf)
|
|||
|
|
FfiConverterOptionUInt32.write(value.best, into: &buf)
|
|||
|
|
FfiConverterUInt32.write(value.cleanStreak, into: &buf)
|
|||
|
|
FfiConverterSequenceUInt32.write(value.recentMistakes, into: &buf)
|
|||
|
|
FfiConverterSequenceBool.write(value.recentHinted, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeTrainStats_lift(_ buf: RustBuffer) throws -> TrainStats {
|
|||
|
|
return try FfiConverterTypeTrainStats.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeTrainStats_lower(_ value: TrainStats) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeTrainStats.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* What looking a nickname up on a site gave.
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
public enum AccountLookup: Equatable, Hashable {
|
|||
|
|
|
|||
|
|
case found(account: OnlineAccount
|
|||
|
|
)
|
|||
|
|
case notFound
|
|||
|
|
case failed(failure: OnlineFailure
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension AccountLookup: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeAccountLookup: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = AccountLookup
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountLookup {
|
|||
|
|
let variant: Int32 = try readInt(&buf)
|
|||
|
|
switch variant {
|
|||
|
|
|
|||
|
|
case 1: return .found(account: try FfiConverterTypeOnlineAccount.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
case 2: return .notFound
|
|||
|
|
|
|||
|
|
case 3: return .failed(failure: try FfiConverterTypeOnlineFailure.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
default: throw UniffiInternalError.unexpectedEnumCase
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: AccountLookup, into buf: inout [UInt8]) {
|
|||
|
|
switch value {
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .found(account):
|
|||
|
|
writeInt(&buf, Int32(1))
|
|||
|
|
FfiConverterTypeOnlineAccount.write(account, into: &buf)
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .notFound:
|
|||
|
|
writeInt(&buf, Int32(2))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .failed(failure):
|
|||
|
|
writeInt(&buf, Int32(3))
|
|||
|
|
FfiConverterTypeOnlineFailure.write(failure, into: &buf)
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeAccountLookup_lift(_ buf: RustBuffer) throws -> AccountLookup {
|
|||
|
|
return try FfiConverterTypeAccountLookup.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeAccountLookup_lower(_ value: AccountLookup) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeAccountLookup.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* What went wrong opening or reading a database, in words for the user (the Kotlin
|
|||
|
|
* side shows them as they are, or picks its own text by kind).
|
|||
|
|
*/
|
|||
|
|
public
|
|||
|
|
enum ApiError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError {
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The file could not be read.
|
|||
|
|
*/
|
|||
|
|
case Io(detail: String
|
|||
|
|
)
|
|||
|
|
/**
|
|||
|
|
* A known format that cannot be read (password, ChessBase 2CBH).
|
|||
|
|
*/
|
|||
|
|
case Unsupported(detail: String
|
|||
|
|
)
|
|||
|
|
/**
|
|||
|
|
* The file is damaged or not a database.
|
|||
|
|
*/
|
|||
|
|
case Corrupt(detail: String
|
|||
|
|
)
|
|||
|
|
/**
|
|||
|
|
* An archive without a database inside.
|
|||
|
|
*/
|
|||
|
|
case Empty
|
|||
|
|
/**
|
|||
|
|
* No game with this number.
|
|||
|
|
*/
|
|||
|
|
case NoGame(index: UInt32
|
|||
|
|
)
|
|||
|
|
/**
|
|||
|
|
* No move at this place of the game's list.
|
|||
|
|
*/
|
|||
|
|
case NoNode(place: UInt32
|
|||
|
|
)
|
|||
|
|
/**
|
|||
|
|
* A change of the game that cannot be made (an illegal move, …).
|
|||
|
|
*/
|
|||
|
|
case Edit(detail: String
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public var errorDescription: String? {
|
|||
|
|
String(reflecting: self)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension ApiError: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeApiError: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = ApiError
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ApiError {
|
|||
|
|
let variant: Int32 = try readInt(&buf)
|
|||
|
|
switch variant {
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
case 1: return .Io(
|
|||
|
|
detail: try FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
case 2: return .Unsupported(
|
|||
|
|
detail: try FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
case 3: return .Corrupt(
|
|||
|
|
detail: try FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
case 4: return .Empty
|
|||
|
|
case 5: return .NoGame(
|
|||
|
|
index: try FfiConverterUInt32.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
case 6: return .NoNode(
|
|||
|
|
place: try FfiConverterUInt32.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
case 7: return .Edit(
|
|||
|
|
detail: try FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
default: throw UniffiInternalError.unexpectedEnumCase
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: ApiError, into buf: inout [UInt8]) {
|
|||
|
|
switch value {
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .Io(detail):
|
|||
|
|
writeInt(&buf, Int32(1))
|
|||
|
|
FfiConverterString.write(detail, into: &buf)
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .Unsupported(detail):
|
|||
|
|
writeInt(&buf, Int32(2))
|
|||
|
|
FfiConverterString.write(detail, into: &buf)
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .Corrupt(detail):
|
|||
|
|
writeInt(&buf, Int32(3))
|
|||
|
|
FfiConverterString.write(detail, into: &buf)
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .Empty:
|
|||
|
|
writeInt(&buf, Int32(4))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .NoGame(index):
|
|||
|
|
writeInt(&buf, Int32(5))
|
|||
|
|
FfiConverterUInt32.write(index, into: &buf)
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .NoNode(place):
|
|||
|
|
writeInt(&buf, Int32(6))
|
|||
|
|
FfiConverterUInt32.write(place, into: &buf)
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .Edit(detail):
|
|||
|
|
writeInt(&buf, Int32(7))
|
|||
|
|
FfiConverterString.write(detail, into: &buf)
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeApiError_lift(_ buf: RustBuffer) throws -> ApiError {
|
|||
|
|
return try FfiConverterTypeApiError.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeApiError_lower(_ value: ApiError) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeApiError.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Why the engine cannot serve.
|
|||
|
|
*/
|
|||
|
|
public
|
|||
|
|
enum EngineFailure: Swift.Error, Equatable, Hashable, Foundation.LocalizedError {
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The engine did not start or did not answer the handshake.
|
|||
|
|
*/
|
|||
|
|
case Start(detail: String
|
|||
|
|
)
|
|||
|
|
/**
|
|||
|
|
* The position cannot be sent (a bad FEN or move).
|
|||
|
|
*/
|
|||
|
|
case Input(detail: String
|
|||
|
|
)
|
|||
|
|
/**
|
|||
|
|
* The engine has stopped (it crashed, hung and was killed, or was quit).
|
|||
|
|
*/
|
|||
|
|
case Stopped(detail: String
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public var errorDescription: String? {
|
|||
|
|
String(reflecting: self)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension EngineFailure: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeEngineFailure: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = EngineFailure
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> EngineFailure {
|
|||
|
|
let variant: Int32 = try readInt(&buf)
|
|||
|
|
switch variant {
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
case 1: return .Start(
|
|||
|
|
detail: try FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
case 2: return .Input(
|
|||
|
|
detail: try FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
case 3: return .Stopped(
|
|||
|
|
detail: try FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
default: throw UniffiInternalError.unexpectedEnumCase
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: EngineFailure, into buf: inout [UInt8]) {
|
|||
|
|
switch value {
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .Start(detail):
|
|||
|
|
writeInt(&buf, Int32(1))
|
|||
|
|
FfiConverterString.write(detail, into: &buf)
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .Input(detail):
|
|||
|
|
writeInt(&buf, Int32(2))
|
|||
|
|
FfiConverterString.write(detail, into: &buf)
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .Stopped(detail):
|
|||
|
|
writeInt(&buf, Int32(3))
|
|||
|
|
FfiConverterString.write(detail, into: &buf)
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeEngineFailure_lift(_ buf: RustBuffer) throws -> EngineFailure {
|
|||
|
|
return try FfiConverterTypeEngineFailure.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeEngineFailure_lower(_ value: EngineFailure) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeEngineFailure.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* How a game stands at a position: over or not.
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
public enum GameEnding: Equatable, Hashable {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The side named won by mate.
|
|||
|
|
*/
|
|||
|
|
case checkmate(whiteWon: Bool
|
|||
|
|
)
|
|||
|
|
case stalemate
|
|||
|
|
case insufficientMaterial
|
|||
|
|
case threefold
|
|||
|
|
case fiftyMoves
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension GameEnding: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeGameEnding: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = GameEnding
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GameEnding {
|
|||
|
|
let variant: Int32 = try readInt(&buf)
|
|||
|
|
switch variant {
|
|||
|
|
|
|||
|
|
case 1: return .checkmate(whiteWon: try FfiConverterBool.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
case 2: return .stalemate
|
|||
|
|
|
|||
|
|
case 3: return .insufficientMaterial
|
|||
|
|
|
|||
|
|
case 4: return .threefold
|
|||
|
|
|
|||
|
|
case 5: return .fiftyMoves
|
|||
|
|
|
|||
|
|
default: throw UniffiInternalError.unexpectedEnumCase
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: GameEnding, into buf: inout [UInt8]) {
|
|||
|
|
switch value {
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .checkmate(whiteWon):
|
|||
|
|
writeInt(&buf, Int32(1))
|
|||
|
|
FfiConverterBool.write(whiteWon, into: &buf)
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .stalemate:
|
|||
|
|
writeInt(&buf, Int32(2))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .insufficientMaterial:
|
|||
|
|
writeInt(&buf, Int32(3))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .threefold:
|
|||
|
|
writeInt(&buf, Int32(4))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .fiftyMoves:
|
|||
|
|
writeInt(&buf, Int32(5))
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeGameEnding_lift(_ buf: RustBuffer) throws -> GameEnding {
|
|||
|
|
return try FfiConverterTypeGameEnding.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeGameEnding_lower(_ value: GameEnding) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeGameEnding.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* How bad a move was, or that it was of note.
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
public enum MoveJudgement: Equatable, Hashable {
|
|||
|
|
|
|||
|
|
case inaccuracy
|
|||
|
|
case mistake
|
|||
|
|
case blunder
|
|||
|
|
/**
|
|||
|
|
* The only good move, or one that turned the game (!).
|
|||
|
|
*/
|
|||
|
|
case great
|
|||
|
|
/**
|
|||
|
|
* A sound sacrifice of a piece (!!).
|
|||
|
|
*/
|
|||
|
|
case brilliant
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension MoveJudgement: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeMoveJudgement: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = MoveJudgement
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MoveJudgement {
|
|||
|
|
let variant: Int32 = try readInt(&buf)
|
|||
|
|
switch variant {
|
|||
|
|
|
|||
|
|
case 1: return .inaccuracy
|
|||
|
|
|
|||
|
|
case 2: return .mistake
|
|||
|
|
|
|||
|
|
case 3: return .blunder
|
|||
|
|
|
|||
|
|
case 4: return .great
|
|||
|
|
|
|||
|
|
case 5: return .brilliant
|
|||
|
|
|
|||
|
|
default: throw UniffiInternalError.unexpectedEnumCase
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: MoveJudgement, into buf: inout [UInt8]) {
|
|||
|
|
switch value {
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .inaccuracy:
|
|||
|
|
writeInt(&buf, Int32(1))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .mistake:
|
|||
|
|
writeInt(&buf, Int32(2))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .blunder:
|
|||
|
|
writeInt(&buf, Int32(3))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .great:
|
|||
|
|
writeInt(&buf, Int32(4))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .brilliant:
|
|||
|
|
writeInt(&buf, Int32(5))
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeMoveJudgement_lift(_ buf: RustBuffer) throws -> MoveJudgement {
|
|||
|
|
return try FfiConverterTypeMoveJudgement.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeMoveJudgement_lower(_ value: MoveJudgement) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeMoveJudgement.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* What went wrong talking to a site.
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
public enum OnlineProblem: Equatable, Hashable {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* No answer (offline, a timeout).
|
|||
|
|
*/
|
|||
|
|
case network
|
|||
|
|
/**
|
|||
|
|
* The site asks for a pause: too many requests.
|
|||
|
|
*/
|
|||
|
|
case rateLimited
|
|||
|
|
/**
|
|||
|
|
* An answer this version does not understand (the site changed).
|
|||
|
|
*/
|
|||
|
|
case unexpected
|
|||
|
|
/**
|
|||
|
|
* The database could not be written (the phone is full).
|
|||
|
|
*/
|
|||
|
|
case disk
|
|||
|
|
/**
|
|||
|
|
* The database is being downloaded already.
|
|||
|
|
*/
|
|||
|
|
case busy
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension OnlineProblem: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeOnlineProblem: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = OnlineProblem
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> OnlineProblem {
|
|||
|
|
let variant: Int32 = try readInt(&buf)
|
|||
|
|
switch variant {
|
|||
|
|
|
|||
|
|
case 1: return .network
|
|||
|
|
|
|||
|
|
case 2: return .rateLimited
|
|||
|
|
|
|||
|
|
case 3: return .unexpected
|
|||
|
|
|
|||
|
|
case 4: return .disk
|
|||
|
|
|
|||
|
|
case 5: return .busy
|
|||
|
|
|
|||
|
|
default: throw UniffiInternalError.unexpectedEnumCase
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: OnlineProblem, into buf: inout [UInt8]) {
|
|||
|
|
switch value {
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .network:
|
|||
|
|
writeInt(&buf, Int32(1))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .rateLimited:
|
|||
|
|
writeInt(&buf, Int32(2))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .unexpected:
|
|||
|
|
writeInt(&buf, Int32(3))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .disk:
|
|||
|
|
writeInt(&buf, Int32(4))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .busy:
|
|||
|
|
writeInt(&buf, Int32(5))
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeOnlineProblem_lift(_ buf: RustBuffer) throws -> OnlineProblem {
|
|||
|
|
return try FfiConverterTypeOnlineProblem.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeOnlineProblem_lower(_ value: OnlineProblem) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeOnlineProblem.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* The phase of a [`PrepSearch`]. Terminal phases are `Ready`, `Cancelled`,
|
|||
|
|
* `NoMemory` and `Failed`.
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
public enum PrepPhase: Equatable, Hashable {
|
|||
|
|
|
|||
|
|
case games
|
|||
|
|
case index
|
|||
|
|
case search
|
|||
|
|
case ready
|
|||
|
|
case cancelled
|
|||
|
|
case noMemory
|
|||
|
|
case failed
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension PrepPhase: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypePrepPhase: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = PrepPhase
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PrepPhase {
|
|||
|
|
let variant: Int32 = try readInt(&buf)
|
|||
|
|
switch variant {
|
|||
|
|
|
|||
|
|
case 1: return .games
|
|||
|
|
|
|||
|
|
case 2: return .index
|
|||
|
|
|
|||
|
|
case 3: return .search
|
|||
|
|
|
|||
|
|
case 4: return .ready
|
|||
|
|
|
|||
|
|
case 5: return .cancelled
|
|||
|
|
|
|||
|
|
case 6: return .noMemory
|
|||
|
|
|
|||
|
|
case 7: return .failed
|
|||
|
|
|
|||
|
|
default: throw UniffiInternalError.unexpectedEnumCase
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: PrepPhase, into buf: inout [UInt8]) {
|
|||
|
|
switch value {
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .games:
|
|||
|
|
writeInt(&buf, Int32(1))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .index:
|
|||
|
|
writeInt(&buf, Int32(2))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .search:
|
|||
|
|
writeInt(&buf, Int32(3))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .ready:
|
|||
|
|
writeInt(&buf, Int32(4))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .cancelled:
|
|||
|
|
writeInt(&buf, Int32(5))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .noMemory:
|
|||
|
|
writeInt(&buf, Int32(6))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .failed:
|
|||
|
|
writeInt(&buf, Int32(7))
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePrepPhase_lift(_ buf: RustBuffer) throws -> PrepPhase {
|
|||
|
|
return try FfiConverterTypePrepPhase.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypePrepPhase_lower(_ value: PrepPhase) -> RustBuffer {
|
|||
|
|
return FfiConverterTypePrepPhase.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
public enum ReleaseCheck: Equatable, Hashable {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* This app is the latest release (or newer: a build from the sources), or the newer
|
|||
|
|
* release has nothing for Android (a desktop-only one).
|
|||
|
|
*/
|
|||
|
|
case upToDate(latest: String
|
|||
|
|
)
|
|||
|
|
case newer(release: AppRelease
|
|||
|
|
)
|
|||
|
|
/**
|
|||
|
|
* A newer release whose light APK cannot be checked: no `SHA256SUMS.txt`, or no sum
|
|||
|
|
* for the file in it.
|
|||
|
|
*/
|
|||
|
|
case unverifiable(release: AppRelease
|
|||
|
|
)
|
|||
|
|
/**
|
|||
|
|
* No answer: `detail` for the log.
|
|||
|
|
*/
|
|||
|
|
case failed(detail: String
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension ReleaseCheck: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeReleaseCheck: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = ReleaseCheck
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ReleaseCheck {
|
|||
|
|
let variant: Int32 = try readInt(&buf)
|
|||
|
|
switch variant {
|
|||
|
|
|
|||
|
|
case 1: return .upToDate(latest: try FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
case 2: return .newer(release: try FfiConverterTypeAppRelease.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
case 3: return .unverifiable(release: try FfiConverterTypeAppRelease.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
case 4: return .failed(detail: try FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
default: throw UniffiInternalError.unexpectedEnumCase
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: ReleaseCheck, into buf: inout [UInt8]) {
|
|||
|
|
switch value {
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .upToDate(latest):
|
|||
|
|
writeInt(&buf, Int32(1))
|
|||
|
|
FfiConverterString.write(latest, into: &buf)
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .newer(release):
|
|||
|
|
writeInt(&buf, Int32(2))
|
|||
|
|
FfiConverterTypeAppRelease.write(release, into: &buf)
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .unverifiable(release):
|
|||
|
|
writeInt(&buf, Int32(3))
|
|||
|
|
FfiConverterTypeAppRelease.write(release, into: &buf)
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .failed(detail):
|
|||
|
|
writeInt(&buf, Int32(4))
|
|||
|
|
FfiConverterString.write(detail, into: &buf)
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeReleaseCheck_lift(_ buf: RustBuffer) throws -> ReleaseCheck {
|
|||
|
|
return try FfiConverterTypeReleaseCheck.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeReleaseCheck_lower(_ value: ReleaseCheck) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeReleaseCheck.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Who plays against the user.
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
public enum Rival: Equatable, Hashable {
|
|||
|
|
|
|||
|
|
case maia
|
|||
|
|
/**
|
|||
|
|
* Rodent IV in a style of its list (`iv_tal`…).
|
|||
|
|
*/
|
|||
|
|
case rodent(styleId: String
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension Rival: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeRival: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = Rival
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Rival {
|
|||
|
|
let variant: Int32 = try readInt(&buf)
|
|||
|
|
switch variant {
|
|||
|
|
|
|||
|
|
case 1: return .maia
|
|||
|
|
|
|||
|
|
case 2: return .rodent(styleId: try FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
default: throw UniffiInternalError.unexpectedEnumCase
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: Rival, into buf: inout [UInt8]) {
|
|||
|
|
switch value {
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .maia:
|
|||
|
|
writeInt(&buf, Int32(1))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .rodent(styleId):
|
|||
|
|
writeInt(&buf, Int32(2))
|
|||
|
|
FfiConverterString.write(styleId, into: &buf)
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeRival_lift(_ buf: RustBuffer) throws -> Rival {
|
|||
|
|
return try FfiConverterTypeRival.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeRival_lower(_ value: Rival) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeRival.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* Why Rodent does not play: it did not start (the engine's words), or it stopped
|
|||
|
|
* during the game (android-rodent.md §6.6).
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
public enum RodentFailure: Equatable, Hashable {
|
|||
|
|
|
|||
|
|
case didNotStart(detail: String
|
|||
|
|
)
|
|||
|
|
case stopped
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension RodentFailure: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeRodentFailure: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = RodentFailure
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RodentFailure {
|
|||
|
|
let variant: Int32 = try readInt(&buf)
|
|||
|
|
switch variant {
|
|||
|
|
|
|||
|
|
case 1: return .didNotStart(detail: try FfiConverterString.read(from: &buf)
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
case 2: return .stopped
|
|||
|
|
|
|||
|
|
default: throw UniffiInternalError.unexpectedEnumCase
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: RodentFailure, into buf: inout [UInt8]) {
|
|||
|
|
switch value {
|
|||
|
|
|
|||
|
|
|
|||
|
|
case let .didNotStart(detail):
|
|||
|
|
writeInt(&buf, Int32(1))
|
|||
|
|
FfiConverterString.write(detail, into: &buf)
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .stopped:
|
|||
|
|
writeInt(&buf, Int32(2))
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeRodentFailure_lift(_ buf: RustBuffer) throws -> RodentFailure {
|
|||
|
|
return try FfiConverterTypeRodentFailure.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeRodentFailure_lower(_ value: RodentFailure) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeRodentFailure.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* A site.
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
public enum Site: Equatable, Hashable {
|
|||
|
|
|
|||
|
|
case lichess
|
|||
|
|
case chessCom
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension Site: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeSite: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = Site
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Site {
|
|||
|
|
let variant: Int32 = try readInt(&buf)
|
|||
|
|
switch variant {
|
|||
|
|
|
|||
|
|
case 1: return .lichess
|
|||
|
|
|
|||
|
|
case 2: return .chessCom
|
|||
|
|
|
|||
|
|
default: throw UniffiInternalError.unexpectedEnumCase
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: Site, into buf: inout [UInt8]) {
|
|||
|
|
switch value {
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .lichess:
|
|||
|
|
writeInt(&buf, Int32(1))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .chessCom:
|
|||
|
|
writeInt(&buf, Int32(2))
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeSite_lift(_ buf: RustBuffer) throws -> Site {
|
|||
|
|
return try FfiConverterTypeSite.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeSite_lower(_ value: Site) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeSite.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* What a move made was.
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
public enum TrainVerdict: Equatable, Hashable {
|
|||
|
|
|
|||
|
|
case right
|
|||
|
|
case finished
|
|||
|
|
case wrong
|
|||
|
|
case done
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if compiler(>=6)
|
|||
|
|
extension TrainVerdict: Sendable {}
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public struct FfiConverterTypeTrainVerdict: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = TrainVerdict
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TrainVerdict {
|
|||
|
|
let variant: Int32 = try readInt(&buf)
|
|||
|
|
switch variant {
|
|||
|
|
|
|||
|
|
case 1: return .right
|
|||
|
|
|
|||
|
|
case 2: return .finished
|
|||
|
|
|
|||
|
|
case 3: return .wrong
|
|||
|
|
|
|||
|
|
case 4: return .done
|
|||
|
|
|
|||
|
|
default: throw UniffiInternalError.unexpectedEnumCase
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func write(_ value: TrainVerdict, into buf: inout [UInt8]) {
|
|||
|
|
switch value {
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .right:
|
|||
|
|
writeInt(&buf, Int32(1))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .finished:
|
|||
|
|
writeInt(&buf, Int32(2))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .wrong:
|
|||
|
|
writeInt(&buf, Int32(3))
|
|||
|
|
|
|||
|
|
|
|||
|
|
case .done:
|
|||
|
|
writeInt(&buf, Int32(4))
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeTrainVerdict_lift(_ buf: RustBuffer) throws -> TrainVerdict {
|
|||
|
|
return try FfiConverterTypeTrainVerdict.lift(buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
public func FfiConverterTypeTrainVerdict_lower(_ value: TrainVerdict) -> RustBuffer {
|
|||
|
|
return FfiConverterTypeTrainVerdict.lower(value)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
#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 FfiConverterOptionUInt64: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = UInt64?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterUInt64.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 FfiConverterUInt64.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 FfiConverterOptionFloat: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = Float?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterFloat.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 FfiConverterFloat.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionDouble: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = Double?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterDouble.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 FfiConverterDouble.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionBool: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = Bool?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterBool.write(value, into: &buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
|
|||
|
|
switch try readInt(&buf) as Int8 {
|
|||
|
|
case 0: return nil
|
|||
|
|
case 1: return try FfiConverterBool.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionString: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = String?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterString.write(value, into: &buf)
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
|
|||
|
|
switch try readInt(&buf) as Int8 {
|
|||
|
|
case 0: return nil
|
|||
|
|
case 1: return try FfiConverterString.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionTypeTrainer: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = Trainer?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterTypeTrainer.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 FfiConverterTypeTrainer.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionTypeAnalysis: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = Analysis?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterTypeAnalysis.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 FfiConverterTypeAnalysis.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionTypeApkFile: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = ApkFile?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterTypeApkFile.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 FfiConverterTypeApkFile.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionTypeEdited: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = Edited?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterTypeEdited.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 FfiConverterTypeEdited.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionTypeEngineLine: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = EngineLine?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterTypeEngineLine.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 FfiConverterTypeEngineLine.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionTypeOnlineDatabase: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = OnlineDatabase?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterTypeOnlineDatabase.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 FfiConverterTypeOnlineDatabase.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionTypeOnlineFailure: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = OnlineFailure?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterTypeOnlineFailure.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 FfiConverterTypeOnlineFailure.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionTypePrepResult: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = PrepResult?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterTypePrepResult.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 FfiConverterTypePrepResult.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionTypeTrainStats: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = TrainStats?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterTypeTrainStats.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 FfiConverterTypeTrainStats.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionTypeGameEnding: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = GameEnding?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterTypeGameEnding.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 FfiConverterTypeGameEnding.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionTypeMoveJudgement: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = MoveJudgement?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterTypeMoveJudgement.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 FfiConverterTypeMoveJudgement.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionTypeRodentFailure: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = RodentFailure?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterTypeRodentFailure.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 FfiConverterTypeRodentFailure.read(from: &buf)
|
|||
|
|
default: throw UniffiInternalError.unexpectedOptionalTag
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterOptionTypeSite: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = Site?
|
|||
|
|
|
|||
|
|
public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
|
|||
|
|
guard let value = value else {
|
|||
|
|
writeInt(&buf, Int8(0))
|
|||
|
|
return
|
|||
|
|
}
|
|||
|
|
writeInt(&buf, Int8(1))
|
|||
|
|
FfiConverterTypeSite.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 FfiConverterTypeSite.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 FfiConverterSequenceUInt32: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [UInt32]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [UInt32], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterUInt32.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [UInt32] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [UInt32]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterUInt32.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceBool: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [Bool]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [Bool], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterBool.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Bool] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [Bool]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterBool.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#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 FfiConverterSequenceTypeEngineLine: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [EngineLine]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [EngineLine], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypeEngineLine.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [EngineLine] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [EngineLine]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypeEngineLine.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypeFolderFile: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [FolderFile]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [FolderFile], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypeFolderFile.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [FolderFile] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [FolderFile]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypeFolderFile.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypeGameRow: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [GameRow]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [GameRow], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypeGameRow.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [GameRow] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [GameRow]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypeGameRow.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypeLineStep: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [LineStep]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [LineStep], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypeLineStep.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [LineStep] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [LineStep]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypeLineStep.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypeMark: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [Mark]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [Mark], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypeMark.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Mark] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [Mark]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypeMark.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypeMoveNode: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [MoveNode]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [MoveNode], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypeMoveNode.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [MoveNode] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [MoveNode]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypeMoveNode.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypeOnlineAccount: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [OnlineAccount]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [OnlineAccount], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypeOnlineAccount.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [OnlineAccount] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [OnlineAccount]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypeOnlineAccount.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypeOnlineTarget: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [OnlineTarget]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [OnlineTarget], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypeOnlineTarget.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [OnlineTarget] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [OnlineTarget]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypeOnlineTarget.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypePlayerSuggestion: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [PlayerSuggestion]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [PlayerSuggestion], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypePlayerSuggestion.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PlayerSuggestion] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [PlayerSuggestion]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypePlayerSuggestion.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypePrepContinuation: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [PrepContinuation]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [PrepContinuation], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypePrepContinuation.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PrepContinuation] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [PrepContinuation]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypePrepContinuation.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypePrepMatch: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [PrepMatch]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [PrepMatch], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypePrepMatch.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [PrepMatch] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [PrepMatch]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypePrepMatch.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypeReviewMove: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [ReviewMove]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [ReviewMove], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypeReviewMove.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ReviewMove] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [ReviewMove]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypeReviewMove.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypeReviewPoint: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [ReviewPoint]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [ReviewPoint], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypeReviewPoint.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ReviewPoint] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [ReviewPoint]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypeReviewPoint.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypeRodentBook: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [RodentBook]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [RodentBook], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypeRodentBook.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [RodentBook] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [RodentBook]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypeRodentBook.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypeRodentStyle: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [RodentStyle]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [RodentStyle], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypeRodentStyle.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [RodentStyle] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [RodentStyle]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypeRodentStyle.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#if swift(>=5.8)
|
|||
|
|
@_documentation(visibility: private)
|
|||
|
|
#endif
|
|||
|
|
fileprivate struct FfiConverterSequenceTypeTag: FfiConverterRustBuffer {
|
|||
|
|
typealias SwiftType = [Tag]
|
|||
|
|
|
|||
|
|
public static func write(_ value: [Tag], into buf: inout [UInt8]) {
|
|||
|
|
let len = Int32(value.count)
|
|||
|
|
writeInt(&buf, len)
|
|||
|
|
for item in value {
|
|||
|
|
FfiConverterTypeTag.write(item, into: &buf)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Tag] {
|
|||
|
|
let len: Int32 = try readInt(&buf)
|
|||
|
|
var seq = [Tag]()
|
|||
|
|
seq.reserveCapacity(Int(len))
|
|||
|
|
for _ in 0 ..< len {
|
|||
|
|
seq.append(try FfiConverterTypeTag.read(from: &buf))
|
|||
|
|
}
|
|||
|
|
return seq
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Opens a database file given as its content.
|
|||
|
|
*/
|
|||
|
|
public func openBytes(name: String, bytes: Data)throws -> Database {
|
|||
|
|
return try FfiConverterTypeDatabase_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_open_bytes(
|
|||
|
|
FfiConverterString.lower(name),
|
|||
|
|
FfiConverterData.lower(bytes),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Opens the ChessBase database `cbh_name` from the files of its folder (the `.cbh`
|
|||
|
|
* and the files beside it with the same name; others are closed unread).
|
|||
|
|
*/
|
|||
|
|
public func openChessbase(cbhName: String, files: [FolderFile])throws -> Database {
|
|||
|
|
return try FfiConverterTypeDatabase_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_open_chessbase(
|
|||
|
|
FfiConverterString.lower(cbhName),
|
|||
|
|
FfiConverterSequenceTypeFolderFile.lower(files),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Opens a database file (PGN, `.zip`, `.7z`, `.cbv`) from a file descriptor; the
|
|||
|
|
* descriptor is taken over and closed (on Android: `ParcelFileDescriptor.detachFd()`).
|
|||
|
|
* `name` is the file's name, for its extension.
|
|||
|
|
*/
|
|||
|
|
public func openFile(name: String, fd: Int32)throws -> Database {
|
|||
|
|
return try FfiConverterTypeDatabase_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_open_file(
|
|||
|
|
FfiConverterString.lower(name),
|
|||
|
|
FfiConverterInt32.lower(fd),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Opens a database by its path (tests, tools; the app uses descriptors).
|
|||
|
|
*/
|
|||
|
|
public func openPath(path: String)throws -> Database {
|
|||
|
|
return try FfiConverterTypeDatabase_lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_open_path(
|
|||
|
|
FfiConverterString.lower(path),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Deletes a downloaded database and the files beside it (its state).
|
|||
|
|
*/
|
|||
|
|
public func deleteOnlineDatabase(path: String) {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_delete_online_database(
|
|||
|
|
FfiConverterString.lower(path),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Looks the nickname up on the site (blocks: it asks the site).
|
|||
|
|
*/
|
|||
|
|
public func findAccount(site: Site, nick: String) -> AccountLookup {
|
|||
|
|
return try! FfiConverterTypeAccountLookup_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_find_account(
|
|||
|
|
FfiConverterTypeSite_lower(site),
|
|||
|
|
FfiConverterString.lower(nick),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* The state of the database at `path`, when it is a downloaded one.
|
|||
|
|
*/
|
|||
|
|
public func onlineDatabase(path: String) -> OnlineDatabase? {
|
|||
|
|
return try! FfiConverterOptionTypeOnlineDatabase.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_online_database(
|
|||
|
|
FfiConverterString.lower(path),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Where the found accounts go in `dir`: all into one database (`together`) or each into
|
|||
|
|
* its own; a database already holding them is kept.
|
|||
|
|
*/
|
|||
|
|
public func onlineTargets(dir: String, accounts: [OnlineAccount], together: Bool) -> [OnlineTarget] {
|
|||
|
|
return try! FfiConverterSequenceTypeOnlineTarget.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_online_targets(
|
|||
|
|
FfiConverterString.lower(dir),
|
|||
|
|
FfiConverterSequenceTypeOnlineAccount.lower(accounts),
|
|||
|
|
FfiConverterBool.lower(together),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* A nickname both sites could have: 2–30 letters, digits, `_` or `-`.
|
|||
|
|
*/
|
|||
|
|
public func validNickname(nick: String) -> Bool {
|
|||
|
|
return try! FfiConverterBool.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_valid_nickname(
|
|||
|
|
FfiConverterString.lower(nick),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* The tags of a game against the computer on the phone (no clocks): `event` in the
|
|||
|
|
* app's language; the user plays White when `user_white`.
|
|||
|
|
*/
|
|||
|
|
public func computerGameTags(event: String, userWhite: Bool, userName: String, rival: Rival, strength: UInt32) -> [Tag] {
|
|||
|
|
return try! FfiConverterSequenceTypeTag.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_computer_game_tags(
|
|||
|
|
FfiConverterString.lower(event),
|
|||
|
|
FfiConverterBool.lower(userWhite),
|
|||
|
|
FfiConverterString.lower(userName),
|
|||
|
|
FfiConverterTypeRival_lower(rival),
|
|||
|
|
FfiConverterUInt32.lower(strength),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Maia's turns in a row with her position hopeless before she offers to resign.
|
|||
|
|
*/
|
|||
|
|
public func hopelessTurns() -> UInt32 {
|
|||
|
|
return try! FfiConverterUInt32.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_hopeless_turns(uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* The strengths Maia plays on her own scale, as on the desktop: (weakest, strongest).
|
|||
|
|
*/
|
|||
|
|
public func maiaRange() -> [UInt32] {
|
|||
|
|
return try! FfiConverterSequenceUInt32.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_maia_range(uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* How long the computer "thinks" before its move `ply` of an untimed game
|
|||
|
|
* (milliseconds): as a person would, quicker with one legal move.
|
|||
|
|
*/
|
|||
|
|
public func movePauseMs(ply: UInt32, onlyMove: Bool) -> UInt64 {
|
|||
|
|
return try! FfiConverterUInt64.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_move_pause_ms(
|
|||
|
|
FfiConverterUInt32.lower(ply),
|
|||
|
|
FfiConverterBool.lower(onlyMove),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* The opponent as the app shows it, without the style: «Maia 1500», «Rodent IV 1800».
|
|||
|
|
*/
|
|||
|
|
public func rivalLabel(rival: Rival, strength: UInt32) -> String {
|
|||
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_rival_label(
|
|||
|
|
FfiConverterTypeRival_lower(rival),
|
|||
|
|
FfiConverterUInt32.lower(strength),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* The opponent as the game's record names it: «Maia 1500», «Rodent IV 1800 (Tal)».
|
|||
|
|
*/
|
|||
|
|
public func rivalName(rival: Rival, strength: UInt32) -> String {
|
|||
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_rival_name(
|
|||
|
|
FfiConverterTypeRival_lower(rival),
|
|||
|
|
FfiConverterUInt32.lower(strength),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* The opening books Rodent IV's characters open, downloaded as one pack
|
|||
|
|
* (android-rodent.md §5).
|
|||
|
|
*/
|
|||
|
|
public func rodentBookPack() -> [RodentBook] {
|
|||
|
|
return try! FfiConverterSequenceTypeRodentBook.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_rodent_book_pack(uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* The strengths Rodent IV plays (its UCI_Elo): (weakest, strongest).
|
|||
|
|
*/
|
|||
|
|
public func rodentRange() -> [UInt32] {
|
|||
|
|
return try! FfiConverterSequenceUInt32.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_rodent_range(uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Rodent IV's characters (the desktop's list; Rodent V is not on the phone).
|
|||
|
|
*/
|
|||
|
|
public func rodentStyles() -> [RodentStyle] {
|
|||
|
|
return try! FfiConverterSequenceTypeRodentStyle.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_rodent_styles(uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* The version of Rodent IV's files (the authors' commit): the personalities copied out
|
|||
|
|
* of the APK are copied again when it changes.
|
|||
|
|
*/
|
|||
|
|
public func rodentVersion() -> String {
|
|||
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_rodent_version(uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Seconds `searches` engine searches of the game analysis take at `nps_per_process`
|
|||
|
|
* nodes per second of one engine process (measured before, or a guess), in this
|
|||
|
|
* phone's engine processes.
|
|||
|
|
*/
|
|||
|
|
public func reviewEstimateSecs(searches: UInt32, npsPerProcess: UInt64) -> UInt32 {
|
|||
|
|
return try! FfiConverterUInt32.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_review_estimate_secs(
|
|||
|
|
FfiConverterUInt32.lower(searches),
|
|||
|
|
FfiConverterUInt64.lower(npsPerProcess),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Makes a new empty own database at `path` (refused when the file exists).
|
|||
|
|
*/
|
|||
|
|
public func ownCreate(path: String)throws {try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_own_create(
|
|||
|
|
FfiConverterString.lower(path),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Removes game `index` from the own database at `path`.
|
|||
|
|
*/
|
|||
|
|
public func ownRemove(path: String, index: UInt32)throws {try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_own_remove(
|
|||
|
|
FfiConverterString.lower(path),
|
|||
|
|
FfiConverterUInt32.lower(index),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Saves the game `pgn` into the own database at `path`: as game `index` (replacing
|
|||
|
|
* it), or added at the end when `index` is `None`. Returns the game's number.
|
|||
|
|
*/
|
|||
|
|
public func ownSave(path: String, index: UInt32?, pgn: String)throws -> UInt32 {
|
|||
|
|
return try FfiConverterUInt32.lift(try rustCallWithError(FfiConverterTypeApiError_lift) {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_own_save(
|
|||
|
|
FfiConverterString.lower(path),
|
|||
|
|
FfiConverterOptionUInt32.lower(index),
|
|||
|
|
FfiConverterString.lower(pgn),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Where the runs are kept (`training.json` in the app's files).
|
|||
|
|
*/
|
|||
|
|
public func trainerSetFile(path: String) {try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_trainer_set_file(
|
|||
|
|
FfiConverterString.lower(path),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Asks `api` (a test server) for the latest release; a newer one comes with its APKs.
|
|||
|
|
*/
|
|||
|
|
public func checkRelease(api: String) -> ReleaseCheck {
|
|||
|
|
return try! FfiConverterTypeReleaseCheck_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_check_release(
|
|||
|
|
FfiConverterString.lower(api),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* Asks the site for the latest release, counting this installation for the day (its
|
|||
|
|
* random `install` id and `platform`: "android" or "android-noengine"); without the
|
|||
|
|
* site, GitHub. A newer release comes with its APKs.
|
|||
|
|
*/
|
|||
|
|
public func checkReleaseCounted(install: String, platform: String) -> ReleaseCheck {
|
|||
|
|
return try! FfiConverterTypeReleaseCheck_lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_check_release_counted(
|
|||
|
|
FfiConverterString.lower(install),
|
|||
|
|
FfiConverterString.lower(platform),uniffiCallStatus
|
|||
|
|
)
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
/**
|
|||
|
|
* GitHub's answer for the latest release (a debug build may ask a test server).
|
|||
|
|
*/
|
|||
|
|
public func releaseApi() -> String {
|
|||
|
|
return try! FfiConverterString.lift(try! rustCall() {
|
|||
|
|
uniffiCallStatus in
|
|||
|
|
uniffi_mobile_api_fn_func_release_api(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_mobile_api_uniffi_contract_version()
|
|||
|
|
if bindings_contract_version != scaffolding_contract_version {
|
|||
|
|
return InitializationResult.contractVersionMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_open_bytes() != 45696) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_open_chessbase() != 34293) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_open_file() != 41660) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_open_path() != 3159) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_delete_online_database() != 10827) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_find_account() != 34245) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_online_database() != 14641) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_online_targets() != 17914) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_valid_nickname() != 20440) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_computer_game_tags() != 13978) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_hopeless_turns() != 4716) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_maia_range() != 8445) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_move_pause_ms() != 46916) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_rival_label() != 1851) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_rival_name() != 50702) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_rodent_book_pack() != 6165) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_rodent_range() != 30309) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_rodent_styles() != 6717) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_rodent_version() != 17337) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_review_estimate_secs() != 59010) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_own_create() != 43565) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_own_remove() != 39994) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_own_save() != 29490) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_trainer_set_file() != 24709) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_check_release() != 17738) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_check_release_counted() != 54959) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_func_release_api() != 51397) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_database_find() != 41701) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_database_format() != 62190) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_database_game() != 13948) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_database_is_empty() != 3355) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_database_len() != 39534) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_database_newest_first() != 25840) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_database_notes() != 8568) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_database_pgn() != 14) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_database_review() != 20396) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_database_rows() != 55855) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_database_rows_of() != 22834) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_database_session() != 13281) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_database_prepare_position() != 11767) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_database_suggest_players() != 46681) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_analyzer_analyze() != 34144) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_analyzer_poll() != 45771) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_analyzer_quit() != 45344) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_analyzer_stop() != 50787) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_onlinedownload_cancel() != 32278) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_onlinedownload_state() != 46119) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_maiaplayer_choose() != 14997) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_resignjudge_ask() != 1694) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_resignjudge_forget() != 52931) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_resignjudge_forget_scores() != 9173) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_resignjudge_hopeless() != 5608) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_resignjudge_may_offer_draw() != 60609) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_resignjudge_offer_draw() != 17768) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_rodentplayer_choose() != 22740) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_rodentplayer_failure() != 64959) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_rodentplayer_forget() != 65358) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_prepsearch_cancel() != 5927) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_prepsearch_state() != 37530) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamereview_cancel() != 25049) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamereview_start() != 54716) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamereview_state() != 48523) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_ending() != 17995) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_add_comment() != 41399) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_add_line() != 61827) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_can_redo() != 7738) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_can_undo() != 32279) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_data() != 35662) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_delete_from() != 34708) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_is_modified() != 910) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_legal_moves() != 48605) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_make_main() != 45389) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_mark_saved() != 12000) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_pgn() != 56097) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_play() != 3894) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_play_from() != 7019) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_redo() != 42738) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_review() != 55508) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_set_data() != 43756) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_undo() != 49960) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_trainer() != 14323) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_gamesession_training_runs() != 31571) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_trainer_again() != 43209) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_trainer_event() != 16815) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_trainer_fen_after() != 21411) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_trainer_game() != 8370) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_trainer_judge() != 41333) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_trainer_legal_moves() != 28204) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_trainer_promotion_at() != 23166) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_trainer_show() != 12978) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_trainer_state() != 11667) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_method_trainer_up_to() != 28864) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_constructor_analyzer_start() != 48571) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_constructor_onlinedownload_start() != 6799) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_constructor_maiaplayer_load() != 29545) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_constructor_resignjudge_start() != 7151) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_constructor_rodentplayer_start() != 41669) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_constructor_gamesession_from_pgn() != 23248) {
|
|||
|
|
return InitializationResult.apiChecksumMismatch
|
|||
|
|
}
|
|||
|
|
if (uniffi_mobile_api_checksum_constructor_gamesession_new_game() != 14475) {
|
|||
|
|
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 uniffiEnsureMobileApiInitialized() {
|
|||
|
|
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
|