// 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(fjord_coreFFI)
import fjord_coreFFI
#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_fjord_core_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_fjord_core_rustbuffer_free(self, $0) }
    }
}

fileprivate extension ForeignBytes {
    init(bufferPointer: UnsafeBufferPointer<UInt8>) {
        self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress)
    }
}

// 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 {
    uniffiEnsureInitialized()
    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))
    }
}
fileprivate class UniffiHandleMap<T> {
    private var map: [UInt64: T] = [:]
    private let lock = NSLock()
    private var currentHandle: UInt64 = 1

    func insert(obj: T) -> UInt64 {
        lock.withLock {
            let handle = currentHandle
            currentHandle += 1
            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
        }
    }

    @discardableResult
    func remove(handle: UInt64) throws -> T {
        try lock.withLock {
            guard let obj = map.removeValue(forKey: handle) else {
                throw UniffiInternalError.unexpectedStaleHandle
            }
            return obj
        }
    }

    var count: Int {
        get {
            map.count
        }
    }
}


// Public interface members begin here.


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterUInt16: FfiConverterPrimitive {
    typealias FfiType = UInt16
    typealias SwiftType = UInt16

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt16 {
        return try lift(readInt(&buf))
    }

    public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
        writeInt(&buf, lower(value))
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterUInt32: FfiConverterPrimitive {
    typealias FfiType = UInt32
    typealias SwiftType = UInt32

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt32 {
        return try lift(readInt(&buf))
    }

    public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
        writeInt(&buf, lower(value))
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct 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 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))
        return String(bytes: bytes, encoding: String.Encoding.utf8)!
    }

    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)
        return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)!
    }

    public static func write(_ value: String, into buf: inout [UInt8]) {
        let len = Int32(value.utf8.count)
        writeInt(&buf, len)
        writeBytes(&buf, value.utf8)
    }
}




/**
 * Set by the shell when the user dismisses the sign-in sheet. The flow checks
 * it before every wait slice and every poll.
 */
public protocol CancelFlagProtocol : AnyObject {
    
    func cancel() 
    
    func isCancelled()  -> Bool
    
}

/**
 * Set by the shell when the user dismisses the sign-in sheet. The flow checks
 * it before every wait slice and every poll.
 */
open class CancelFlag:
    CancelFlagProtocol {
    fileprivate let pointer: UnsafeMutableRawPointer!

    /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly.
#if swift(>=5.8)
    @_documentation(visibility: private)
#endif
    public struct NoPointer {
        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`.
    required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
        self.pointer = pointer
    }

    // This constructor can be used to instantiate a fake object.
    // - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash.
#if swift(>=5.8)
    @_documentation(visibility: private)
#endif
    public init(noPointer: NoPointer) {
        self.pointer = nil
    }

#if swift(>=5.8)
    @_documentation(visibility: private)
#endif
    public func uniffiClonePointer() -> UnsafeMutableRawPointer {
        return try! rustCall { uniffi_fjord_core_fn_clone_cancelflag(self.pointer, $0) }
    }
public convenience init() {
    let pointer =
        try! rustCall() {
    uniffi_fjord_core_fn_constructor_cancelflag_new($0
    )
}
    self.init(unsafeFromRawPointer: pointer)
}

    deinit {
        guard let pointer = pointer else {
            return
        }

        try! rustCall { uniffi_fjord_core_fn_free_cancelflag(pointer, $0) }
    }

    

    
open func cancel() {try! rustCall() {
    uniffi_fjord_core_fn_method_cancelflag_cancel(self.uniffiClonePointer(),$0
    )
}
}
    
open func isCancelled() -> Bool {
    return try!  FfiConverterBool.lift(try! rustCall() {
    uniffi_fjord_core_fn_method_cancelflag_is_cancelled(self.uniffiClonePointer(),$0
    )
})
}
    

}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCancelFlag: FfiConverter {

    typealias FfiType = UnsafeMutableRawPointer
    typealias SwiftType = CancelFlag

    public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> CancelFlag {
        return CancelFlag(unsafeFromRawPointer: pointer)
    }

    public static func lower(_ value: CancelFlag) -> UnsafeMutableRawPointer {
        return value.uniffiClonePointer()
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CancelFlag {
        let v: UInt64 = try readInt(&buf)
        // The Rust code won't compile if a pointer won't fit in a UInt64.
        // We have to go via `UInt` because that's the thing that's the size of a pointer.
        let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v))
        if (ptr == nil) {
            throw UniffiInternalError.unexpectedNullPointer
        }
        return try lift(ptr!)
    }

    public static func write(_ value: CancelFlag, into buf: inout [UInt8]) {
        // This fiddling is because `Int` is the thing that's the same size as a pointer.
        // The Rust code won't compile if a pointer won't fit in a `UInt64`.
        writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value)))))
    }
}




#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCancelFlag_lift(_ pointer: UnsafeMutableRawPointer) throws -> CancelFlag {
    return try FfiConverterTypeCancelFlag.lift(pointer)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCancelFlag_lower(_ value: CancelFlag) -> UnsafeMutableRawPointer {
    return FfiConverterTypeCancelFlag.lower(value)
}




/**
 * The reads one signed-in account can make, whatever its forge. Built once
 * per account; every method reads as that account.
 */
public protocol ProviderHandleProtocol : AnyObject {
    
    /**
     * The account this handle reads as.
     */
    func account()  -> AccountRef
    
    /**
     * Every check and status on `commit_sha` in `repo`, with the rollup.
     */
    func checkStatus(repo: ItemRef, commitSha: String, cancel: CancelFlag) async throws  -> CheckStatus
    
    /**
     * The unified diff of a pull request.
     */
    func diff(pullRequest: ItemRef, cancel: CancelFlag) async throws  -> String
    
    /**
     * Open pull requests in `repo`, a `repo_ref` from a listed repository.
     */
    func listPullRequests(repo: ItemRef, page: PageToken?, cancel: CancelFlag) async throws  -> ChangeRequestPage
    
    /**
     * Repositories the account can read, most recently updated first.
     */
    func listRepositories(page: PageToken?, cancel: CancelFlag) async throws  -> RepoPage
    
    /**
     * One pull request, including merge readiness.
     */
    func pullRequest(pullRequest: ItemRef, cancel: CancelFlag) async throws  -> ChangeRequest
    
}

/**
 * The reads one signed-in account can make, whatever its forge. Built once
 * per account; every method reads as that account.
 */
open class ProviderHandle:
    ProviderHandleProtocol {
    fileprivate let pointer: UnsafeMutableRawPointer!

    /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly.
#if swift(>=5.8)
    @_documentation(visibility: private)
#endif
    public struct NoPointer {
        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`.
    required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
        self.pointer = pointer
    }

    // This constructor can be used to instantiate a fake object.
    // - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash.
#if swift(>=5.8)
    @_documentation(visibility: private)
#endif
    public init(noPointer: NoPointer) {
        self.pointer = nil
    }

#if swift(>=5.8)
    @_documentation(visibility: private)
#endif
    public func uniffiClonePointer() -> UnsafeMutableRawPointer {
        return try! rustCall { uniffi_fjord_core_fn_clone_providerhandle(self.pointer, $0) }
    }
    /**
     * The handle for `account`, reading its token from `tokens` once per
     * request. A provider this build has no adapter for is `Unsupported`.
     */
public convenience init(account: AccountRef, tokens: TokenStore)throws  {
    let pointer =
        try rustCallWithError(FfiConverterTypeForgeCallError.lift) {
    uniffi_fjord_core_fn_constructor_providerhandle_new(
        FfiConverterTypeAccountRef.lower(account),
        FfiConverterTypeTokenStore.lower(tokens),$0
    )
}
    self.init(unsafeFromRawPointer: pointer)
}

    deinit {
        guard let pointer = pointer else {
            return
        }

        try! rustCall { uniffi_fjord_core_fn_free_providerhandle(pointer, $0) }
    }

    

    
    /**
     * The account this handle reads as.
     */
open func account() -> AccountRef {
    return try!  FfiConverterTypeAccountRef.lift(try! rustCall() {
    uniffi_fjord_core_fn_method_providerhandle_account(self.uniffiClonePointer(),$0
    )
})
}
    
    /**
     * Every check and status on `commit_sha` in `repo`, with the rollup.
     */
open func checkStatus(repo: ItemRef, commitSha: String, cancel: CancelFlag)async throws  -> CheckStatus {
    return
        try  await uniffiRustCallAsync(
            rustFutureFunc: {
                uniffi_fjord_core_fn_method_providerhandle_check_status(
                    self.uniffiClonePointer(),
                    FfiConverterTypeItemRef.lower(repo),FfiConverterString.lower(commitSha),FfiConverterTypeCancelFlag.lower(cancel)
                )
            },
            pollFunc: ffi_fjord_core_rust_future_poll_rust_buffer,
            completeFunc: ffi_fjord_core_rust_future_complete_rust_buffer,
            freeFunc: ffi_fjord_core_rust_future_free_rust_buffer,
            liftFunc: FfiConverterTypeCheckStatus.lift,
            errorHandler: FfiConverterTypeForgeCallError.lift
        )
}
    
    /**
     * The unified diff of a pull request.
     */
open func diff(pullRequest: ItemRef, cancel: CancelFlag)async throws  -> String {
    return
        try  await uniffiRustCallAsync(
            rustFutureFunc: {
                uniffi_fjord_core_fn_method_providerhandle_diff(
                    self.uniffiClonePointer(),
                    FfiConverterTypeItemRef.lower(pullRequest),FfiConverterTypeCancelFlag.lower(cancel)
                )
            },
            pollFunc: ffi_fjord_core_rust_future_poll_rust_buffer,
            completeFunc: ffi_fjord_core_rust_future_complete_rust_buffer,
            freeFunc: ffi_fjord_core_rust_future_free_rust_buffer,
            liftFunc: FfiConverterString.lift,
            errorHandler: FfiConverterTypeForgeCallError.lift
        )
}
    
    /**
     * Open pull requests in `repo`, a `repo_ref` from a listed repository.
     */
open func listPullRequests(repo: ItemRef, page: PageToken?, cancel: CancelFlag)async throws  -> ChangeRequestPage {
    return
        try  await uniffiRustCallAsync(
            rustFutureFunc: {
                uniffi_fjord_core_fn_method_providerhandle_list_pull_requests(
                    self.uniffiClonePointer(),
                    FfiConverterTypeItemRef.lower(repo),FfiConverterOptionTypePageToken.lower(page),FfiConverterTypeCancelFlag.lower(cancel)
                )
            },
            pollFunc: ffi_fjord_core_rust_future_poll_rust_buffer,
            completeFunc: ffi_fjord_core_rust_future_complete_rust_buffer,
            freeFunc: ffi_fjord_core_rust_future_free_rust_buffer,
            liftFunc: FfiConverterTypeChangeRequestPage.lift,
            errorHandler: FfiConverterTypeForgeCallError.lift
        )
}
    
    /**
     * Repositories the account can read, most recently updated first.
     */
open func listRepositories(page: PageToken?, cancel: CancelFlag)async throws  -> RepoPage {
    return
        try  await uniffiRustCallAsync(
            rustFutureFunc: {
                uniffi_fjord_core_fn_method_providerhandle_list_repositories(
                    self.uniffiClonePointer(),
                    FfiConverterOptionTypePageToken.lower(page),FfiConverterTypeCancelFlag.lower(cancel)
                )
            },
            pollFunc: ffi_fjord_core_rust_future_poll_rust_buffer,
            completeFunc: ffi_fjord_core_rust_future_complete_rust_buffer,
            freeFunc: ffi_fjord_core_rust_future_free_rust_buffer,
            liftFunc: FfiConverterTypeRepoPage.lift,
            errorHandler: FfiConverterTypeForgeCallError.lift
        )
}
    
    /**
     * One pull request, including merge readiness.
     */
open func pullRequest(pullRequest: ItemRef, cancel: CancelFlag)async throws  -> ChangeRequest {
    return
        try  await uniffiRustCallAsync(
            rustFutureFunc: {
                uniffi_fjord_core_fn_method_providerhandle_pull_request(
                    self.uniffiClonePointer(),
                    FfiConverterTypeItemRef.lower(pullRequest),FfiConverterTypeCancelFlag.lower(cancel)
                )
            },
            pollFunc: ffi_fjord_core_rust_future_poll_rust_buffer,
            completeFunc: ffi_fjord_core_rust_future_complete_rust_buffer,
            freeFunc: ffi_fjord_core_rust_future_free_rust_buffer,
            liftFunc: FfiConverterTypeChangeRequest.lift,
            errorHandler: FfiConverterTypeForgeCallError.lift
        )
}
    

}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeProviderHandle: FfiConverter {

    typealias FfiType = UnsafeMutableRawPointer
    typealias SwiftType = ProviderHandle

    public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> ProviderHandle {
        return ProviderHandle(unsafeFromRawPointer: pointer)
    }

    public static func lower(_ value: ProviderHandle) -> UnsafeMutableRawPointer {
        return value.uniffiClonePointer()
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ProviderHandle {
        let v: UInt64 = try readInt(&buf)
        // The Rust code won't compile if a pointer won't fit in a UInt64.
        // We have to go via `UInt` because that's the thing that's the size of a pointer.
        let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v))
        if (ptr == nil) {
            throw UniffiInternalError.unexpectedNullPointer
        }
        return try lift(ptr!)
    }

    public static func write(_ value: ProviderHandle, into buf: inout [UInt8]) {
        // This fiddling is because `Int` is the thing that's the same size as a pointer.
        // The Rust code won't compile if a pointer won't fit in a `UInt64`.
        writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value)))))
    }
}




#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeProviderHandle_lift(_ pointer: UnsafeMutableRawPointer) throws -> ProviderHandle {
    return try FfiConverterTypeProviderHandle.lift(pointer)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeProviderHandle_lower(_ value: ProviderHandle) -> UnsafeMutableRawPointer {
    return FfiConverterTypeProviderHandle.lower(value)
}




/**
 * Implemented by the shell. Core reads, never writes: the shell saves a token
 * after sign-in and deletes it on sign-out.
 */
public protocol TokenStore : AnyObject {
    
    /**
     * The token for `account`, or `None` when the account has none (signed
     * out, or removed).
     */
    func token(account: AccountRef) throws  -> String?
    
}

/**
 * Implemented by the shell. Core reads, never writes: the shell saves a token
 * after sign-in and deletes it on sign-out.
 */
open class TokenStoreImpl:
    TokenStore {
    fileprivate let pointer: UnsafeMutableRawPointer!

    /// Used to instantiate a [FFIObject] without an actual pointer, for fakes in tests, mostly.
#if swift(>=5.8)
    @_documentation(visibility: private)
#endif
    public struct NoPointer {
        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`.
    required public init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
        self.pointer = pointer
    }

    // This constructor can be used to instantiate a fake object.
    // - Parameter noPointer: 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 [Pointer] the FFI lower functions will crash.
#if swift(>=5.8)
    @_documentation(visibility: private)
#endif
    public init(noPointer: NoPointer) {
        self.pointer = nil
    }

#if swift(>=5.8)
    @_documentation(visibility: private)
#endif
    public func uniffiClonePointer() -> UnsafeMutableRawPointer {
        return try! rustCall { uniffi_fjord_core_fn_clone_tokenstore(self.pointer, $0) }
    }
    // No primary constructor declared for this class.

    deinit {
        guard let pointer = pointer else {
            return
        }

        try! rustCall { uniffi_fjord_core_fn_free_tokenstore(pointer, $0) }
    }

    

    
    /**
     * The token for `account`, or `None` when the account has none (signed
     * out, or removed).
     */
open func token(account: AccountRef)throws  -> String? {
    return try  FfiConverterOptionString.lift(try rustCallWithError(FfiConverterTypeTokenStoreError.lift) {
    uniffi_fjord_core_fn_method_tokenstore_token(self.uniffiClonePointer(),
        FfiConverterTypeAccountRef.lower(account),$0
    )
})
}
    

}
// Magic number for the Rust proxy to call using the same mechanism as every other method,
// to free the callback once it's dropped by Rust.
private let IDX_CALLBACK_FREE: Int32 = 0
// Callback return codes
private let UNIFFI_CALLBACK_SUCCESS: Int32 = 0
private let UNIFFI_CALLBACK_ERROR: Int32 = 1
private let UNIFFI_CALLBACK_UNEXPECTED_ERROR: Int32 = 2

// Put the implementation in a struct so we don't pollute the top-level namespace
fileprivate struct UniffiCallbackInterfaceTokenStore {

    // Create the VTable using a series of closures.
    // Swift automatically converts these into C callback functions.
    static var vtable: UniffiVTableCallbackInterfaceTokenStore = UniffiVTableCallbackInterfaceTokenStore(
        token: { (
            uniffiHandle: UInt64,
            account: RustBuffer,
            uniffiOutReturn: UnsafeMutablePointer<RustBuffer>,
            uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
        ) in
            let makeCall = {
                () throws -> String? in
                guard let uniffiObj = try? FfiConverterTypeTokenStore.handleMap.get(handle: uniffiHandle) else {
                    throw UniffiInternalError.unexpectedStaleHandle
                }
                return try uniffiObj.token(
                     account: try FfiConverterTypeAccountRef.lift(account)
                )
            }

            
            let writeReturn = { uniffiOutReturn.pointee = FfiConverterOptionString.lower($0) }
            uniffiTraitInterfaceCallWithError(
                callStatus: uniffiCallStatus,
                makeCall: makeCall,
                writeReturn: writeReturn,
                lowerError: FfiConverterTypeTokenStoreError.lower
            )
        },
        uniffiFree: { (uniffiHandle: UInt64) -> () in
            let result = try? FfiConverterTypeTokenStore.handleMap.remove(handle: uniffiHandle)
            if result == nil {
                print("Uniffi callback interface TokenStore: handle missing in uniffiFree")
            }
        }
    )
}

private func uniffiCallbackInitTokenStore() {
    uniffi_fjord_core_fn_init_callback_vtable_tokenstore(&UniffiCallbackInterfaceTokenStore.vtable)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeTokenStore: FfiConverter {
    fileprivate static var handleMap = UniffiHandleMap<TokenStore>()

    typealias FfiType = UnsafeMutableRawPointer
    typealias SwiftType = TokenStore

    public static func lift(_ pointer: UnsafeMutableRawPointer) throws -> TokenStore {
        return TokenStoreImpl(unsafeFromRawPointer: pointer)
    }

    public static func lower(_ value: TokenStore) -> UnsafeMutableRawPointer {
        guard let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: handleMap.insert(obj: value))) else {
            fatalError("Cast to UnsafeMutableRawPointer failed")
        }
        return ptr
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TokenStore {
        let v: UInt64 = try readInt(&buf)
        // The Rust code won't compile if a pointer won't fit in a UInt64.
        // We have to go via `UInt` because that's the thing that's the size of a pointer.
        let ptr = UnsafeMutableRawPointer(bitPattern: UInt(truncatingIfNeeded: v))
        if (ptr == nil) {
            throw UniffiInternalError.unexpectedNullPointer
        }
        return try lift(ptr!)
    }

    public static func write(_ value: TokenStore, into buf: inout [UInt8]) {
        // This fiddling is because `Int` is the thing that's the same size as a pointer.
        // The Rust code won't compile if a pointer won't fit in a `UInt64`.
        writeInt(&buf, UInt64(bitPattern: Int64(Int(bitPattern: lower(value)))))
    }
}




#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeTokenStore_lift(_ pointer: UnsafeMutableRawPointer) throws -> TokenStore {
    return try FfiConverterTypeTokenStore.lift(pointer)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeTokenStore_lower(_ value: TokenStore) -> UnsafeMutableRawPointer {
    return FfiConverterTypeTokenStore.lower(value)
}


/**
 * One entry's absorb group: the target commit to fix up, the entry's branch,
 * and the files headed for it.
 */
public struct AbsorbGroup {
    public var branch: String
    /**
     * The commit (a stack entry's tip) the fixup targets.
     */
    public var target: String
    public var files: [String]

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(branch: String, 
        /**
         * The commit (a stack entry's tip) the fixup targets.
         */target: String, files: [String]) {
        self.branch = branch
        self.target = target
        self.files = files
    }
}



extension AbsorbGroup: Equatable, Hashable {
    public static func ==(lhs: AbsorbGroup, rhs: AbsorbGroup) -> Bool {
        if lhs.branch != rhs.branch {
            return false
        }
        if lhs.target != rhs.target {
            return false
        }
        if lhs.files != rhs.files {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(branch)
        hasher.combine(target)
        hasher.combine(files)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeAbsorbGroup: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AbsorbGroup {
        return
            try AbsorbGroup(
                branch: FfiConverterString.read(from: &buf), 
                target: FfiConverterString.read(from: &buf), 
                files: FfiConverterSequenceString.read(from: &buf)
        )
    }

    public static func write(_ value: AbsorbGroup, into buf: inout [UInt8]) {
        FfiConverterString.write(value.branch, into: &buf)
        FfiConverterString.write(value.target, into: &buf)
        FfiConverterSequenceString.write(value.files, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeAbsorbGroup_lift(_ buf: RustBuffer) throws -> AbsorbGroup {
    return try FfiConverterTypeAbsorbGroup.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeAbsorbGroup_lower(_ value: AbsorbGroup) -> RustBuffer {
    return FfiConverterTypeAbsorbGroup.lower(value)
}


/**
 * The full absorb plan: per-entry groups plus the files left staged.
 */
public struct AbsorbPlan {
    public var groups: [AbsorbGroup]
    /**
     * Files that couldn't be attributed; they stay staged, untouched.
     */
    public var skipped: [String]

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(groups: [AbsorbGroup], 
        /**
         * Files that couldn't be attributed; they stay staged, untouched.
         */skipped: [String]) {
        self.groups = groups
        self.skipped = skipped
    }
}



extension AbsorbPlan: Equatable, Hashable {
    public static func ==(lhs: AbsorbPlan, rhs: AbsorbPlan) -> Bool {
        if lhs.groups != rhs.groups {
            return false
        }
        if lhs.skipped != rhs.skipped {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(groups)
        hasher.combine(skipped)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeAbsorbPlan: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AbsorbPlan {
        return
            try AbsorbPlan(
                groups: FfiConverterSequenceTypeAbsorbGroup.read(from: &buf), 
                skipped: FfiConverterSequenceString.read(from: &buf)
        )
    }

    public static func write(_ value: AbsorbPlan, into buf: inout [UInt8]) {
        FfiConverterSequenceTypeAbsorbGroup.write(value.groups, into: &buf)
        FfiConverterSequenceString.write(value.skipped, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeAbsorbPlan_lift(_ buf: RustBuffer) throws -> AbsorbPlan {
    return try FfiConverterTypeAbsorbPlan.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeAbsorbPlan_lower(_ value: AbsorbPlan) -> RustBuffer {
    return FfiConverterTypeAbsorbPlan.lower(value)
}


/**
 * A Fjord sign-in. Every token lookup and every action names one explicitly;
 * there is no "current account" default.
 */
public struct AccountRef {
    /**
     * Provider name as the contract spells it, e.g. `github`, `forgejo`.
     */
    public var provider: String
    /**
     * Base URL of the instance, or `github.com`.
     */
    public var instance: String
    /**
     * Stable id the shell assigned to this sign-in. Never a list index.
     */
    public var fjordAccountId: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(
        /**
         * Provider name as the contract spells it, e.g. `github`, `forgejo`.
         */provider: String, 
        /**
         * Base URL of the instance, or `github.com`.
         */instance: String, 
        /**
         * Stable id the shell assigned to this sign-in. Never a list index.
         */fjordAccountId: String) {
        self.provider = provider
        self.instance = instance
        self.fjordAccountId = fjordAccountId
    }
}



extension AccountRef: Equatable, Hashable {
    public static func ==(lhs: AccountRef, rhs: AccountRef) -> Bool {
        if lhs.provider != rhs.provider {
            return false
        }
        if lhs.instance != rhs.instance {
            return false
        }
        if lhs.fjordAccountId != rhs.fjordAccountId {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(provider)
        hasher.combine(instance)
        hasher.combine(fjordAccountId)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeAccountRef: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccountRef {
        return
            try AccountRef(
                provider: FfiConverterString.read(from: &buf), 
                instance: FfiConverterString.read(from: &buf), 
                fjordAccountId: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: AccountRef, into buf: inout [UInt8]) {
        FfiConverterString.write(value.provider, into: &buf)
        FfiConverterString.write(value.instance, into: &buf)
        FfiConverterString.write(value.fjordAccountId, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeAccountRef_lift(_ buf: RustBuffer) throws -> AccountRef {
    return try FfiConverterTypeAccountRef.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeAccountRef_lower(_ value: AccountRef) -> RustBuffer {
    return FfiConverterTypeAccountRef.lower(value)
}


/**
 * Why an action failed, in contract terms.
 */
public struct ActionError {
    public var `class`: ErrorClass
    public var detail: ProviderDetail

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(`class`: ErrorClass, detail: ProviderDetail) {
        self.`class` = `class`
        self.detail = detail
    }
}



extension ActionError: Equatable, Hashable {
    public static func ==(lhs: ActionError, rhs: ActionError) -> Bool {
        if lhs.`class` != rhs.`class` {
            return false
        }
        if lhs.detail != rhs.detail {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(`class`)
        hasher.combine(detail)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeActionError: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActionError {
        return
            try ActionError(
                class: FfiConverterTypeErrorClass.read(from: &buf), 
                detail: FfiConverterTypeProviderDetail.read(from: &buf)
        )
    }

    public static func write(_ value: ActionError, into buf: inout [UInt8]) {
        FfiConverterTypeErrorClass.write(value.`class`, into: &buf)
        FfiConverterTypeProviderDetail.write(value.detail, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeActionError_lift(_ buf: RustBuffer) throws -> ActionError {
    return try FfiConverterTypeActionError.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeActionError_lower(_ value: ActionError) -> RustBuffer {
    return FfiConverterTypeActionError.lower(value)
}


/**
 * A request to change something on the provider.
 */
public struct ActionRequest {
    public var action: ActionKind
    public var targetRef: ItemRef
    public var accountRef: AccountRef
    public var idempotencyKey: String
    public var expected: Expected
    /**
     * Comment or review body, when the action takes one.
     */
    public var body: String?

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(action: ActionKind, targetRef: ItemRef, accountRef: AccountRef, idempotencyKey: String, expected: Expected, 
        /**
         * Comment or review body, when the action takes one.
         */body: String?) {
        self.action = action
        self.targetRef = targetRef
        self.accountRef = accountRef
        self.idempotencyKey = idempotencyKey
        self.expected = expected
        self.body = body
    }
}



extension ActionRequest: Equatable, Hashable {
    public static func ==(lhs: ActionRequest, rhs: ActionRequest) -> Bool {
        if lhs.action != rhs.action {
            return false
        }
        if lhs.targetRef != rhs.targetRef {
            return false
        }
        if lhs.accountRef != rhs.accountRef {
            return false
        }
        if lhs.idempotencyKey != rhs.idempotencyKey {
            return false
        }
        if lhs.expected != rhs.expected {
            return false
        }
        if lhs.body != rhs.body {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(action)
        hasher.combine(targetRef)
        hasher.combine(accountRef)
        hasher.combine(idempotencyKey)
        hasher.combine(expected)
        hasher.combine(body)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeActionRequest: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActionRequest {
        return
            try ActionRequest(
                action: FfiConverterTypeActionKind.read(from: &buf), 
                targetRef: FfiConverterTypeItemRef.read(from: &buf), 
                accountRef: FfiConverterTypeAccountRef.read(from: &buf), 
                idempotencyKey: FfiConverterString.read(from: &buf), 
                expected: FfiConverterTypeExpected.read(from: &buf), 
                body: FfiConverterOptionString.read(from: &buf)
        )
    }

    public static func write(_ value: ActionRequest, into buf: inout [UInt8]) {
        FfiConverterTypeActionKind.write(value.action, into: &buf)
        FfiConverterTypeItemRef.write(value.targetRef, into: &buf)
        FfiConverterTypeAccountRef.write(value.accountRef, into: &buf)
        FfiConverterString.write(value.idempotencyKey, into: &buf)
        FfiConverterTypeExpected.write(value.expected, into: &buf)
        FfiConverterOptionString.write(value.body, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeActionRequest_lift(_ buf: RustBuffer) throws -> ActionRequest {
    return try FfiConverterTypeActionRequest.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeActionRequest_lower(_ value: ActionRequest) -> RustBuffer {
    return FfiConverterTypeActionRequest.lower(value)
}


/**
 * The outcome of an action. State comes from `read_after`, a re-read from the
 * provider, never from the write response.
 */
public struct ActionResult {
    public var ok: Bool
    /**
     * The provider's resulting state value, verbatim, when it reports one.
     */
    public var appliedState: String?
    public var error: ActionError?
    public var readAfter: WorkItem?

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(ok: Bool, 
        /**
         * The provider's resulting state value, verbatim, when it reports one.
         */appliedState: String?, error: ActionError?, readAfter: WorkItem?) {
        self.ok = ok
        self.appliedState = appliedState
        self.error = error
        self.readAfter = readAfter
    }
}



extension ActionResult: Equatable, Hashable {
    public static func ==(lhs: ActionResult, rhs: ActionResult) -> Bool {
        if lhs.ok != rhs.ok {
            return false
        }
        if lhs.appliedState != rhs.appliedState {
            return false
        }
        if lhs.error != rhs.error {
            return false
        }
        if lhs.readAfter != rhs.readAfter {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(ok)
        hasher.combine(appliedState)
        hasher.combine(error)
        hasher.combine(readAfter)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeActionResult: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActionResult {
        return
            try ActionResult(
                ok: FfiConverterBool.read(from: &buf), 
                appliedState: FfiConverterOptionString.read(from: &buf), 
                error: FfiConverterOptionTypeActionError.read(from: &buf), 
                readAfter: FfiConverterOptionTypeWorkItem.read(from: &buf)
        )
    }

    public static func write(_ value: ActionResult, into buf: inout [UInt8]) {
        FfiConverterBool.write(value.ok, into: &buf)
        FfiConverterOptionString.write(value.appliedState, into: &buf)
        FfiConverterOptionTypeActionError.write(value.error, into: &buf)
        FfiConverterOptionTypeWorkItem.write(value.readAfter, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeActionResult_lift(_ buf: RustBuffer) throws -> ActionResult {
    return try FfiConverterTypeActionResult.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeActionResult_lower(_ value: ActionResult) -> RustBuffer {
    return FfiConverterTypeActionResult.lower(value)
}


/**
 * A workflow (Actions) run.
 */
public struct ActionRun {
    public var id: Int64
    public var workflowName: String
    public var status: ActionRunStatus
    public var branch: String
    public var commitSha: String
    public var createdAt: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(id: Int64, workflowName: String, status: ActionRunStatus, branch: String, commitSha: String, createdAt: String) {
        self.id = id
        self.workflowName = workflowName
        self.status = status
        self.branch = branch
        self.commitSha = commitSha
        self.createdAt = createdAt
    }
}



extension ActionRun: Equatable, Hashable {
    public static func ==(lhs: ActionRun, rhs: ActionRun) -> Bool {
        if lhs.id != rhs.id {
            return false
        }
        if lhs.workflowName != rhs.workflowName {
            return false
        }
        if lhs.status != rhs.status {
            return false
        }
        if lhs.branch != rhs.branch {
            return false
        }
        if lhs.commitSha != rhs.commitSha {
            return false
        }
        if lhs.createdAt != rhs.createdAt {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(id)
        hasher.combine(workflowName)
        hasher.combine(status)
        hasher.combine(branch)
        hasher.combine(commitSha)
        hasher.combine(createdAt)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeActionRun: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActionRun {
        return
            try ActionRun(
                id: FfiConverterInt64.read(from: &buf), 
                workflowName: FfiConverterString.read(from: &buf), 
                status: FfiConverterTypeActionRunStatus.read(from: &buf), 
                branch: FfiConverterString.read(from: &buf), 
                commitSha: FfiConverterString.read(from: &buf), 
                createdAt: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: ActionRun, into buf: inout [UInt8]) {
        FfiConverterInt64.write(value.id, into: &buf)
        FfiConverterString.write(value.workflowName, into: &buf)
        FfiConverterTypeActionRunStatus.write(value.status, into: &buf)
        FfiConverterString.write(value.branch, into: &buf)
        FfiConverterString.write(value.commitSha, into: &buf)
        FfiConverterString.write(value.createdAt, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeActionRun_lift(_ buf: RustBuffer) throws -> ActionRun {
    return try FfiConverterTypeActionRun.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeActionRun_lower(_ value: ActionRun) -> RustBuffer {
    return FfiConverterTypeActionRun.lower(value)
}


/**
 * One cached record: an opaque JSON `payload` keyed by `(namespace, key)`, with
 * the sync metadata and timestamps the read-through policy needs.
 */
public struct CacheEntry {
    public var namespace: String
    public var key: String
    public var payload: String
    /**
     * The server's ETag, when one was returned, for conditional revalidation.
     */
    public var etag: String?
    public var cachedAtMs: Int64
    public var ttlMs: Int64

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(namespace: String, key: String, payload: String, 
        /**
         * The server's ETag, when one was returned, for conditional revalidation.
         */etag: String?, cachedAtMs: Int64, ttlMs: Int64) {
        self.namespace = namespace
        self.key = key
        self.payload = payload
        self.etag = etag
        self.cachedAtMs = cachedAtMs
        self.ttlMs = ttlMs
    }
}



extension CacheEntry: Equatable, Hashable {
    public static func ==(lhs: CacheEntry, rhs: CacheEntry) -> Bool {
        if lhs.namespace != rhs.namespace {
            return false
        }
        if lhs.key != rhs.key {
            return false
        }
        if lhs.payload != rhs.payload {
            return false
        }
        if lhs.etag != rhs.etag {
            return false
        }
        if lhs.cachedAtMs != rhs.cachedAtMs {
            return false
        }
        if lhs.ttlMs != rhs.ttlMs {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(namespace)
        hasher.combine(key)
        hasher.combine(payload)
        hasher.combine(etag)
        hasher.combine(cachedAtMs)
        hasher.combine(ttlMs)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCacheEntry: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CacheEntry {
        return
            try CacheEntry(
                namespace: FfiConverterString.read(from: &buf), 
                key: FfiConverterString.read(from: &buf), 
                payload: FfiConverterString.read(from: &buf), 
                etag: FfiConverterOptionString.read(from: &buf), 
                cachedAtMs: FfiConverterInt64.read(from: &buf), 
                ttlMs: FfiConverterInt64.read(from: &buf)
        )
    }

    public static func write(_ value: CacheEntry, into buf: inout [UInt8]) {
        FfiConverterString.write(value.namespace, into: &buf)
        FfiConverterString.write(value.key, into: &buf)
        FfiConverterString.write(value.payload, into: &buf)
        FfiConverterOptionString.write(value.etag, into: &buf)
        FfiConverterInt64.write(value.cachedAtMs, into: &buf)
        FfiConverterInt64.write(value.ttlMs, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCacheEntry_lift(_ buf: RustBuffer) throws -> CacheEntry {
    return try FfiConverterTypeCacheEntry.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCacheEntry_lower(_ value: CacheEntry) -> RustBuffer {
    return FfiConverterTypeCacheEntry.lower(value)
}


/**
 * The tunable cache policy: the default freshness window plus the eviction
 * bounds (drop anything older than `max_age_ms`, and keep at most
 * `max_entries`). One place to assert the rules every client shares.
 */
public struct CachePolicy {
    /**
     * Default TTL applied when an entry does not carry its own.
     */
    public var defaultTtlMs: Int64
    /**
     * Hard age ceiling: entries older than this are evicted regardless of TTL.
     */
    public var maxAgeMs: Int64
    /**
     * Cap on stored entries; the oldest beyond it are evicted.
     */
    public var maxEntries: UInt32

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(
        /**
         * Default TTL applied when an entry does not carry its own.
         */defaultTtlMs: Int64, 
        /**
         * Hard age ceiling: entries older than this are evicted regardless of TTL.
         */maxAgeMs: Int64, 
        /**
         * Cap on stored entries; the oldest beyond it are evicted.
         */maxEntries: UInt32) {
        self.defaultTtlMs = defaultTtlMs
        self.maxAgeMs = maxAgeMs
        self.maxEntries = maxEntries
    }
}



extension CachePolicy: Equatable, Hashable {
    public static func ==(lhs: CachePolicy, rhs: CachePolicy) -> Bool {
        if lhs.defaultTtlMs != rhs.defaultTtlMs {
            return false
        }
        if lhs.maxAgeMs != rhs.maxAgeMs {
            return false
        }
        if lhs.maxEntries != rhs.maxEntries {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(defaultTtlMs)
        hasher.combine(maxAgeMs)
        hasher.combine(maxEntries)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCachePolicy: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CachePolicy {
        return
            try CachePolicy(
                defaultTtlMs: FfiConverterInt64.read(from: &buf), 
                maxAgeMs: FfiConverterInt64.read(from: &buf), 
                maxEntries: FfiConverterUInt32.read(from: &buf)
        )
    }

    public static func write(_ value: CachePolicy, into buf: inout [UInt8]) {
        FfiConverterInt64.write(value.defaultTtlMs, into: &buf)
        FfiConverterInt64.write(value.maxAgeMs, into: &buf)
        FfiConverterUInt32.write(value.maxEntries, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCachePolicy_lift(_ buf: RustBuffer) throws -> CachePolicy {
    return try FfiConverterTypeCachePolicy.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCachePolicy_lower(_ value: CachePolicy) -> RustBuffer {
    return FfiConverterTypeCachePolicy.lower(value)
}


/**
 * The result of a capability probe for one account.
 */
public struct Capabilities {
    public var accountRef: AccountRef
    public var provider: ProviderKind
    public var instance: String
    /**
     * The server version the probe read, when the provider reports one.
     */
    public var providerVersion: String?
    public var contractVersion: String
    public var can: CapabilityFlags

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(accountRef: AccountRef, provider: ProviderKind, instance: String, 
        /**
         * The server version the probe read, when the provider reports one.
         */providerVersion: String?, contractVersion: String, can: CapabilityFlags) {
        self.accountRef = accountRef
        self.provider = provider
        self.instance = instance
        self.providerVersion = providerVersion
        self.contractVersion = contractVersion
        self.can = can
    }
}



extension Capabilities: Equatable, Hashable {
    public static func ==(lhs: Capabilities, rhs: Capabilities) -> Bool {
        if lhs.accountRef != rhs.accountRef {
            return false
        }
        if lhs.provider != rhs.provider {
            return false
        }
        if lhs.instance != rhs.instance {
            return false
        }
        if lhs.providerVersion != rhs.providerVersion {
            return false
        }
        if lhs.contractVersion != rhs.contractVersion {
            return false
        }
        if lhs.can != rhs.can {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(accountRef)
        hasher.combine(provider)
        hasher.combine(instance)
        hasher.combine(providerVersion)
        hasher.combine(contractVersion)
        hasher.combine(can)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCapabilities: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Capabilities {
        return
            try Capabilities(
                accountRef: FfiConverterTypeAccountRef.read(from: &buf), 
                provider: FfiConverterTypeProviderKind.read(from: &buf), 
                instance: FfiConverterString.read(from: &buf), 
                providerVersion: FfiConverterOptionString.read(from: &buf), 
                contractVersion: FfiConverterString.read(from: &buf), 
                can: FfiConverterTypeCapabilityFlags.read(from: &buf)
        )
    }

    public static func write(_ value: Capabilities, into buf: inout [UInt8]) {
        FfiConverterTypeAccountRef.write(value.accountRef, into: &buf)
        FfiConverterTypeProviderKind.write(value.provider, into: &buf)
        FfiConverterString.write(value.instance, into: &buf)
        FfiConverterOptionString.write(value.providerVersion, into: &buf)
        FfiConverterString.write(value.contractVersion, into: &buf)
        FfiConverterTypeCapabilityFlags.write(value.can, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCapabilities_lift(_ buf: RustBuffer) throws -> Capabilities {
    return try FfiConverterTypeCapabilities.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCapabilities_lower(_ value: Capabilities) -> RustBuffer {
    return FfiConverterTypeCapabilities.lower(value)
}


/**
 * The capability flags the UI and the action layer read.
 */
public struct CapabilityFlags {
    public var reviewRequestWrite: Flag
    public var rerun: Flag
    public var cancel: Flag
    public var threadCount: Flag
    public var mergeReadinessField: Flag
    public var notificationsPull: Flag
    public var webhooksAvailable: Flag
    public var rateLimitInfo: Flag

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(reviewRequestWrite: Flag, rerun: Flag, cancel: Flag, threadCount: Flag, mergeReadinessField: Flag, notificationsPull: Flag, webhooksAvailable: Flag, rateLimitInfo: Flag) {
        self.reviewRequestWrite = reviewRequestWrite
        self.rerun = rerun
        self.cancel = cancel
        self.threadCount = threadCount
        self.mergeReadinessField = mergeReadinessField
        self.notificationsPull = notificationsPull
        self.webhooksAvailable = webhooksAvailable
        self.rateLimitInfo = rateLimitInfo
    }
}



extension CapabilityFlags: Equatable, Hashable {
    public static func ==(lhs: CapabilityFlags, rhs: CapabilityFlags) -> Bool {
        if lhs.reviewRequestWrite != rhs.reviewRequestWrite {
            return false
        }
        if lhs.rerun != rhs.rerun {
            return false
        }
        if lhs.cancel != rhs.cancel {
            return false
        }
        if lhs.threadCount != rhs.threadCount {
            return false
        }
        if lhs.mergeReadinessField != rhs.mergeReadinessField {
            return false
        }
        if lhs.notificationsPull != rhs.notificationsPull {
            return false
        }
        if lhs.webhooksAvailable != rhs.webhooksAvailable {
            return false
        }
        if lhs.rateLimitInfo != rhs.rateLimitInfo {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(reviewRequestWrite)
        hasher.combine(rerun)
        hasher.combine(cancel)
        hasher.combine(threadCount)
        hasher.combine(mergeReadinessField)
        hasher.combine(notificationsPull)
        hasher.combine(webhooksAvailable)
        hasher.combine(rateLimitInfo)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCapabilityFlags: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CapabilityFlags {
        return
            try CapabilityFlags(
                reviewRequestWrite: FfiConverterTypeFlag.read(from: &buf), 
                rerun: FfiConverterTypeFlag.read(from: &buf), 
                cancel: FfiConverterTypeFlag.read(from: &buf), 
                threadCount: FfiConverterTypeFlag.read(from: &buf), 
                mergeReadinessField: FfiConverterTypeFlag.read(from: &buf), 
                notificationsPull: FfiConverterTypeFlag.read(from: &buf), 
                webhooksAvailable: FfiConverterTypeFlag.read(from: &buf), 
                rateLimitInfo: FfiConverterTypeFlag.read(from: &buf)
        )
    }

    public static func write(_ value: CapabilityFlags, into buf: inout [UInt8]) {
        FfiConverterTypeFlag.write(value.reviewRequestWrite, into: &buf)
        FfiConverterTypeFlag.write(value.rerun, into: &buf)
        FfiConverterTypeFlag.write(value.cancel, into: &buf)
        FfiConverterTypeFlag.write(value.threadCount, into: &buf)
        FfiConverterTypeFlag.write(value.mergeReadinessField, into: &buf)
        FfiConverterTypeFlag.write(value.notificationsPull, into: &buf)
        FfiConverterTypeFlag.write(value.webhooksAvailable, into: &buf)
        FfiConverterTypeFlag.write(value.rateLimitInfo, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCapabilityFlags_lift(_ buf: RustBuffer) throws -> CapabilityFlags {
    return try FfiConverterTypeCapabilityFlags.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCapabilityFlags_lower(_ value: CapabilityFlags) -> RustBuffer {
    return FfiConverterTypeCapabilityFlags.lower(value)
}


/**
 * A change request with the fields only change requests have.
 */
public struct ChangeRequest {
    public var item: WorkItem
    public var headRef: String
    public var headSha: String
    public var baseRef: String
    public var mergeReadiness: MergeReadiness

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(item: WorkItem, headRef: String, headSha: String, baseRef: String, mergeReadiness: MergeReadiness) {
        self.item = item
        self.headRef = headRef
        self.headSha = headSha
        self.baseRef = baseRef
        self.mergeReadiness = mergeReadiness
    }
}



extension ChangeRequest: Equatable, Hashable {
    public static func ==(lhs: ChangeRequest, rhs: ChangeRequest) -> Bool {
        if lhs.item != rhs.item {
            return false
        }
        if lhs.headRef != rhs.headRef {
            return false
        }
        if lhs.headSha != rhs.headSha {
            return false
        }
        if lhs.baseRef != rhs.baseRef {
            return false
        }
        if lhs.mergeReadiness != rhs.mergeReadiness {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(item)
        hasher.combine(headRef)
        hasher.combine(headSha)
        hasher.combine(baseRef)
        hasher.combine(mergeReadiness)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeChangeRequest: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChangeRequest {
        return
            try ChangeRequest(
                item: FfiConverterTypeWorkItem.read(from: &buf), 
                headRef: FfiConverterString.read(from: &buf), 
                headSha: FfiConverterString.read(from: &buf), 
                baseRef: FfiConverterString.read(from: &buf), 
                mergeReadiness: FfiConverterTypeMergeReadiness.read(from: &buf)
        )
    }

    public static func write(_ value: ChangeRequest, into buf: inout [UInt8]) {
        FfiConverterTypeWorkItem.write(value.item, into: &buf)
        FfiConverterString.write(value.headRef, into: &buf)
        FfiConverterString.write(value.headSha, into: &buf)
        FfiConverterString.write(value.baseRef, into: &buf)
        FfiConverterTypeMergeReadiness.write(value.mergeReadiness, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeChangeRequest_lift(_ buf: RustBuffer) throws -> ChangeRequest {
    return try FfiConverterTypeChangeRequest.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeChangeRequest_lower(_ value: ChangeRequest) -> RustBuffer {
    return FfiConverterTypeChangeRequest.lower(value)
}


/**
 * One page of open change requests (pull requests).
 */
public struct ChangeRequestPage {
    public var items: [ChangeRequest]
    /**
     * `None` on the last page.
     */
    public var next: PageToken?

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(items: [ChangeRequest], 
        /**
         * `None` on the last page.
         */next: PageToken?) {
        self.items = items
        self.next = next
    }
}



extension ChangeRequestPage: Equatable, Hashable {
    public static func ==(lhs: ChangeRequestPage, rhs: ChangeRequestPage) -> Bool {
        if lhs.items != rhs.items {
            return false
        }
        if lhs.next != rhs.next {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(items)
        hasher.combine(next)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeChangeRequestPage: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ChangeRequestPage {
        return
            try ChangeRequestPage(
                items: FfiConverterSequenceTypeChangeRequest.read(from: &buf), 
                next: FfiConverterOptionTypePageToken.read(from: &buf)
        )
    }

    public static func write(_ value: ChangeRequestPage, into buf: inout [UInt8]) {
        FfiConverterSequenceTypeChangeRequest.write(value.items, into: &buf)
        FfiConverterOptionTypePageToken.write(value.next, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeChangeRequestPage_lift(_ buf: RustBuffer) throws -> ChangeRequestPage {
    return try FfiConverterTypeChangeRequestPage.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeChangeRequestPage_lower(_ value: ChangeRequestPage) -> RustBuffer {
    return FfiConverterTypeChangeRequestPage.lower(value)
}


/**
 * One check or status.
 */
public struct Check {
    public var name: String
    /**
     * The status context or check-suite app, verbatim.
     */
    public var context: String
    public var state: CheckState
    /**
     * The provider's own state (and conclusion) value, verbatim.
     */
    public var stateSource: String
    public var url: String?
    public var startedAt: String?
    public var completedAt: String?
    public var kind: CheckKind
    /**
     * `None` unless branch protection was read for the target branch.
     */
    public var required: Bool?

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(name: String, 
        /**
         * The status context or check-suite app, verbatim.
         */context: String, state: CheckState, 
        /**
         * The provider's own state (and conclusion) value, verbatim.
         */stateSource: String, url: String?, startedAt: String?, completedAt: String?, kind: CheckKind, 
        /**
         * `None` unless branch protection was read for the target branch.
         */required: Bool?) {
        self.name = name
        self.context = context
        self.state = state
        self.stateSource = stateSource
        self.url = url
        self.startedAt = startedAt
        self.completedAt = completedAt
        self.kind = kind
        self.required = required
    }
}



extension Check: Equatable, Hashable {
    public static func ==(lhs: Check, rhs: Check) -> Bool {
        if lhs.name != rhs.name {
            return false
        }
        if lhs.context != rhs.context {
            return false
        }
        if lhs.state != rhs.state {
            return false
        }
        if lhs.stateSource != rhs.stateSource {
            return false
        }
        if lhs.url != rhs.url {
            return false
        }
        if lhs.startedAt != rhs.startedAt {
            return false
        }
        if lhs.completedAt != rhs.completedAt {
            return false
        }
        if lhs.kind != rhs.kind {
            return false
        }
        if lhs.required != rhs.required {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(name)
        hasher.combine(context)
        hasher.combine(state)
        hasher.combine(stateSource)
        hasher.combine(url)
        hasher.combine(startedAt)
        hasher.combine(completedAt)
        hasher.combine(kind)
        hasher.combine(required)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCheck: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Check {
        return
            try Check(
                name: FfiConverterString.read(from: &buf), 
                context: FfiConverterString.read(from: &buf), 
                state: FfiConverterTypeCheckState.read(from: &buf), 
                stateSource: FfiConverterString.read(from: &buf), 
                url: FfiConverterOptionString.read(from: &buf), 
                startedAt: FfiConverterOptionString.read(from: &buf), 
                completedAt: FfiConverterOptionString.read(from: &buf), 
                kind: FfiConverterTypeCheckKind.read(from: &buf), 
                required: FfiConverterOptionBool.read(from: &buf)
        )
    }

    public static func write(_ value: Check, into buf: inout [UInt8]) {
        FfiConverterString.write(value.name, into: &buf)
        FfiConverterString.write(value.context, into: &buf)
        FfiConverterTypeCheckState.write(value.state, into: &buf)
        FfiConverterString.write(value.stateSource, into: &buf)
        FfiConverterOptionString.write(value.url, into: &buf)
        FfiConverterOptionString.write(value.startedAt, into: &buf)
        FfiConverterOptionString.write(value.completedAt, into: &buf)
        FfiConverterTypeCheckKind.write(value.kind, into: &buf)
        FfiConverterOptionBool.write(value.required, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCheck_lift(_ buf: RustBuffer) throws -> Check {
    return try FfiConverterTypeCheck.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCheck_lower(_ value: Check) -> RustBuffer {
    return FfiConverterTypeCheck.lower(value)
}


/**
 * All checks on one commit.
 */
public struct CheckStatus {
    public var envelope: Envelope
    public var commitSha: String
    public var changeRequestRef: ItemRef?
    public var checks: [Check]
    public var rollup: Rollup

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(envelope: Envelope, commitSha: String, changeRequestRef: ItemRef?, checks: [Check], rollup: Rollup) {
        self.envelope = envelope
        self.commitSha = commitSha
        self.changeRequestRef = changeRequestRef
        self.checks = checks
        self.rollup = rollup
    }
}



extension CheckStatus: Equatable, Hashable {
    public static func ==(lhs: CheckStatus, rhs: CheckStatus) -> Bool {
        if lhs.envelope != rhs.envelope {
            return false
        }
        if lhs.commitSha != rhs.commitSha {
            return false
        }
        if lhs.changeRequestRef != rhs.changeRequestRef {
            return false
        }
        if lhs.checks != rhs.checks {
            return false
        }
        if lhs.rollup != rhs.rollup {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(envelope)
        hasher.combine(commitSha)
        hasher.combine(changeRequestRef)
        hasher.combine(checks)
        hasher.combine(rollup)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCheckStatus: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CheckStatus {
        return
            try CheckStatus(
                envelope: FfiConverterTypeEnvelope.read(from: &buf), 
                commitSha: FfiConverterString.read(from: &buf), 
                changeRequestRef: FfiConverterOptionTypeItemRef.read(from: &buf), 
                checks: FfiConverterSequenceTypeCheck.read(from: &buf), 
                rollup: FfiConverterTypeRollup.read(from: &buf)
        )
    }

    public static func write(_ value: CheckStatus, into buf: inout [UInt8]) {
        FfiConverterTypeEnvelope.write(value.envelope, into: &buf)
        FfiConverterString.write(value.commitSha, into: &buf)
        FfiConverterOptionTypeItemRef.write(value.changeRequestRef, into: &buf)
        FfiConverterSequenceTypeCheck.write(value.checks, into: &buf)
        FfiConverterTypeRollup.write(value.rollup, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCheckStatus_lift(_ buf: RustBuffer) throws -> CheckStatus {
    return try FfiConverterTypeCheckStatus.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCheckStatus_lower(_ value: CheckStatus) -> RustBuffer {
    return FfiConverterTypeCheckStatus.lower(value)
}


/**
 * One comment.
 */
public struct Comment {
    public var envelope: Envelope
    public var commentRef: ItemRef
    /**
     * The issue, change request or review this belongs to.
     */
    public var parentRef: ItemRef
    public var author: Identity?
    public var body: String
    public var createdAt: String
    public var editedAt: String?
    public var kind: CommentKind
    /**
     * The review thread, for inline comments.
     */
    public var threadRef: ItemRef?
    /**
     * Inline only; `None` when the provider does not say.
     */
    public var resolved: Bool?
    /**
     * Inline only: file path and line in the diff.
     */
    public var path: String?
    public var line: UInt32?

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(envelope: Envelope, commentRef: ItemRef, 
        /**
         * The issue, change request or review this belongs to.
         */parentRef: ItemRef, author: Identity?, body: String, createdAt: String, editedAt: String?, kind: CommentKind, 
        /**
         * The review thread, for inline comments.
         */threadRef: ItemRef?, 
        /**
         * Inline only; `None` when the provider does not say.
         */resolved: Bool?, 
        /**
         * Inline only: file path and line in the diff.
         */path: String?, line: UInt32?) {
        self.envelope = envelope
        self.commentRef = commentRef
        self.parentRef = parentRef
        self.author = author
        self.body = body
        self.createdAt = createdAt
        self.editedAt = editedAt
        self.kind = kind
        self.threadRef = threadRef
        self.resolved = resolved
        self.path = path
        self.line = line
    }
}



extension Comment: Equatable, Hashable {
    public static func ==(lhs: Comment, rhs: Comment) -> Bool {
        if lhs.envelope != rhs.envelope {
            return false
        }
        if lhs.commentRef != rhs.commentRef {
            return false
        }
        if lhs.parentRef != rhs.parentRef {
            return false
        }
        if lhs.author != rhs.author {
            return false
        }
        if lhs.body != rhs.body {
            return false
        }
        if lhs.createdAt != rhs.createdAt {
            return false
        }
        if lhs.editedAt != rhs.editedAt {
            return false
        }
        if lhs.kind != rhs.kind {
            return false
        }
        if lhs.threadRef != rhs.threadRef {
            return false
        }
        if lhs.resolved != rhs.resolved {
            return false
        }
        if lhs.path != rhs.path {
            return false
        }
        if lhs.line != rhs.line {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(envelope)
        hasher.combine(commentRef)
        hasher.combine(parentRef)
        hasher.combine(author)
        hasher.combine(body)
        hasher.combine(createdAt)
        hasher.combine(editedAt)
        hasher.combine(kind)
        hasher.combine(threadRef)
        hasher.combine(resolved)
        hasher.combine(path)
        hasher.combine(line)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeComment: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Comment {
        return
            try Comment(
                envelope: FfiConverterTypeEnvelope.read(from: &buf), 
                commentRef: FfiConverterTypeItemRef.read(from: &buf), 
                parentRef: FfiConverterTypeItemRef.read(from: &buf), 
                author: FfiConverterOptionTypeIdentity.read(from: &buf), 
                body: FfiConverterString.read(from: &buf), 
                createdAt: FfiConverterString.read(from: &buf), 
                editedAt: FfiConverterOptionString.read(from: &buf), 
                kind: FfiConverterTypeCommentKind.read(from: &buf), 
                threadRef: FfiConverterOptionTypeItemRef.read(from: &buf), 
                resolved: FfiConverterOptionBool.read(from: &buf), 
                path: FfiConverterOptionString.read(from: &buf), 
                line: FfiConverterOptionUInt32.read(from: &buf)
        )
    }

    public static func write(_ value: Comment, into buf: inout [UInt8]) {
        FfiConverterTypeEnvelope.write(value.envelope, into: &buf)
        FfiConverterTypeItemRef.write(value.commentRef, into: &buf)
        FfiConverterTypeItemRef.write(value.parentRef, into: &buf)
        FfiConverterOptionTypeIdentity.write(value.author, into: &buf)
        FfiConverterString.write(value.body, into: &buf)
        FfiConverterString.write(value.createdAt, into: &buf)
        FfiConverterOptionString.write(value.editedAt, into: &buf)
        FfiConverterTypeCommentKind.write(value.kind, into: &buf)
        FfiConverterOptionTypeItemRef.write(value.threadRef, into: &buf)
        FfiConverterOptionBool.write(value.resolved, into: &buf)
        FfiConverterOptionString.write(value.path, into: &buf)
        FfiConverterOptionUInt32.write(value.line, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeComment_lift(_ buf: RustBuffer) throws -> Comment {
    return try FfiConverterTypeComment.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeComment_lower(_ value: Comment) -> RustBuffer {
    return FfiConverterTypeComment.lower(value)
}


/**
 * One commit ahead of the base: its full sha and subject line.
 */
public struct Commit {
    public var sha: String
    public var subject: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(sha: String, subject: String) {
        self.sha = sha
        self.subject = subject
    }
}



extension Commit: Equatable, Hashable {
    public static func ==(lhs: Commit, rhs: Commit) -> Bool {
        if lhs.sha != rhs.sha {
            return false
        }
        if lhs.subject != rhs.subject {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(sha)
        hasher.combine(subject)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCommit: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Commit {
        return
            try Commit(
                sha: FfiConverterString.read(from: &buf), 
                subject: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: Commit, into buf: inout [UInt8]) {
        FfiConverterString.write(value.sha, into: &buf)
        FfiConverterString.write(value.subject, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCommit_lift(_ buf: RustBuffer) throws -> Commit {
    return try FfiConverterTypeCommit.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCommit_lower(_ value: Commit) -> RustBuffer {
    return FfiConverterTypeCommit.lower(value)
}


/**
 * What the shell shows the user while the flow runs.
 */
public struct DevicePrompt {
    public var userCode: String
    public var verificationUri: String
    public var expiresInSecs: UInt64

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(userCode: String, verificationUri: String, expiresInSecs: UInt64) {
        self.userCode = userCode
        self.verificationUri = verificationUri
        self.expiresInSecs = expiresInSecs
    }
}



extension DevicePrompt: Equatable, Hashable {
    public static func ==(lhs: DevicePrompt, rhs: DevicePrompt) -> Bool {
        if lhs.userCode != rhs.userCode {
            return false
        }
        if lhs.verificationUri != rhs.verificationUri {
            return false
        }
        if lhs.expiresInSecs != rhs.expiresInSecs {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(userCode)
        hasher.combine(verificationUri)
        hasher.combine(expiresInSecs)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeDevicePrompt: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DevicePrompt {
        return
            try DevicePrompt(
                userCode: FfiConverterString.read(from: &buf), 
                verificationUri: FfiConverterString.read(from: &buf), 
                expiresInSecs: FfiConverterUInt64.read(from: &buf)
        )
    }

    public static func write(_ value: DevicePrompt, into buf: inout [UInt8]) {
        FfiConverterString.write(value.userCode, into: &buf)
        FfiConverterString.write(value.verificationUri, into: &buf)
        FfiConverterUInt64.write(value.expiresInSecs, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeDevicePrompt_lift(_ buf: RustBuffer) throws -> DevicePrompt {
    return try FfiConverterTypeDevicePrompt.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeDevicePrompt_lower(_ value: DevicePrompt) -> RustBuffer {
    return FfiConverterTypeDevicePrompt.lower(value)
}


/**
 * A finished device sign-in. The shell saves `access_token` in its token
 * store under a new account id; core keeps nothing.
 */
public struct DeviceSignIn {
    public var accessToken: String
    public var validation: SignInValidation

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(accessToken: String, validation: SignInValidation) {
        self.accessToken = accessToken
        self.validation = validation
    }
}



extension DeviceSignIn: Equatable, Hashable {
    public static func ==(lhs: DeviceSignIn, rhs: DeviceSignIn) -> Bool {
        if lhs.accessToken != rhs.accessToken {
            return false
        }
        if lhs.validation != rhs.validation {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(accessToken)
        hasher.combine(validation)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeDeviceSignIn: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> DeviceSignIn {
        return
            try DeviceSignIn(
                accessToken: FfiConverterString.read(from: &buf), 
                validation: FfiConverterTypeSignInValidation.read(from: &buf)
        )
    }

    public static func write(_ value: DeviceSignIn, into buf: inout [UInt8]) {
        FfiConverterString.write(value.accessToken, into: &buf)
        FfiConverterTypeSignInValidation.write(value.validation, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeDeviceSignIn_lift(_ buf: RustBuffer) throws -> DeviceSignIn {
    return try FfiConverterTypeDeviceSignIn.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeDeviceSignIn_lower(_ value: DeviceSignIn) -> RustBuffer {
    return FfiConverterTypeDeviceSignIn.lower(value)
}


/**
 * Where an object came from and when.
 */
public struct Envelope {
    public var contractVersion: String
    public var provider: ProviderKind
    /**
     * Base URL, or `github.com`.
     */
    public var instance: String
    /**
     * The sign-in that read this object.
     */
    public var accountRef: AccountRef
    /**
     * The provider's own id for the object.
     */
    public var sourceId: String
    /**
     * RFC 3339 time the object was read from its source.
     */
    public var readAt: String
    public var basis: Basis
    /**
     * Server version when the provider reports one.
     */
    public var providerVersion: String?

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(contractVersion: String, provider: ProviderKind, 
        /**
         * Base URL, or `github.com`.
         */instance: String, 
        /**
         * The sign-in that read this object.
         */accountRef: AccountRef, 
        /**
         * The provider's own id for the object.
         */sourceId: String, 
        /**
         * RFC 3339 time the object was read from its source.
         */readAt: String, basis: Basis, 
        /**
         * Server version when the provider reports one.
         */providerVersion: String?) {
        self.contractVersion = contractVersion
        self.provider = provider
        self.instance = instance
        self.accountRef = accountRef
        self.sourceId = sourceId
        self.readAt = readAt
        self.basis = basis
        self.providerVersion = providerVersion
    }
}



extension Envelope: Equatable, Hashable {
    public static func ==(lhs: Envelope, rhs: Envelope) -> Bool {
        if lhs.contractVersion != rhs.contractVersion {
            return false
        }
        if lhs.provider != rhs.provider {
            return false
        }
        if lhs.instance != rhs.instance {
            return false
        }
        if lhs.accountRef != rhs.accountRef {
            return false
        }
        if lhs.sourceId != rhs.sourceId {
            return false
        }
        if lhs.readAt != rhs.readAt {
            return false
        }
        if lhs.basis != rhs.basis {
            return false
        }
        if lhs.providerVersion != rhs.providerVersion {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(contractVersion)
        hasher.combine(provider)
        hasher.combine(instance)
        hasher.combine(accountRef)
        hasher.combine(sourceId)
        hasher.combine(readAt)
        hasher.combine(basis)
        hasher.combine(providerVersion)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeEnvelope: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Envelope {
        return
            try Envelope(
                contractVersion: FfiConverterString.read(from: &buf), 
                provider: FfiConverterTypeProviderKind.read(from: &buf), 
                instance: FfiConverterString.read(from: &buf), 
                accountRef: FfiConverterTypeAccountRef.read(from: &buf), 
                sourceId: FfiConverterString.read(from: &buf), 
                readAt: FfiConverterString.read(from: &buf), 
                basis: FfiConverterTypeBasis.read(from: &buf), 
                providerVersion: FfiConverterOptionString.read(from: &buf)
        )
    }

    public static func write(_ value: Envelope, into buf: inout [UInt8]) {
        FfiConverterString.write(value.contractVersion, into: &buf)
        FfiConverterTypeProviderKind.write(value.provider, into: &buf)
        FfiConverterString.write(value.instance, into: &buf)
        FfiConverterTypeAccountRef.write(value.accountRef, into: &buf)
        FfiConverterString.write(value.sourceId, into: &buf)
        FfiConverterString.write(value.readAt, into: &buf)
        FfiConverterTypeBasis.write(value.basis, into: &buf)
        FfiConverterOptionString.write(value.providerVersion, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeEnvelope_lift(_ buf: RustBuffer) throws -> Envelope {
    return try FfiConverterTypeEnvelope.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeEnvelope_lower(_ value: Envelope) -> RustBuffer {
    return FfiConverterTypeEnvelope.lower(value)
}


/**
 * The precondition the user saw. A mismatch is `stale_precondition`, so an
 * approval never lands on a commit the user did not review.
 */
public struct Expected {
    public var headSha: String?
    public var state: String?
    /**
     * The source `updated_at` or version the user saw.
     */
    public var version: String?

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(headSha: String?, state: String?, 
        /**
         * The source `updated_at` or version the user saw.
         */version: String?) {
        self.headSha = headSha
        self.state = state
        self.version = version
    }
}



extension Expected: Equatable, Hashable {
    public static func ==(lhs: Expected, rhs: Expected) -> Bool {
        if lhs.headSha != rhs.headSha {
            return false
        }
        if lhs.state != rhs.state {
            return false
        }
        if lhs.version != rhs.version {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(headSha)
        hasher.combine(state)
        hasher.combine(version)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeExpected: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Expected {
        return
            try Expected(
                headSha: FfiConverterOptionString.read(from: &buf), 
                state: FfiConverterOptionString.read(from: &buf), 
                version: FfiConverterOptionString.read(from: &buf)
        )
    }

    public static func write(_ value: Expected, into buf: inout [UInt8]) {
        FfiConverterOptionString.write(value.headSha, into: &buf)
        FfiConverterOptionString.write(value.state, into: &buf)
        FfiConverterOptionString.write(value.version, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeExpected_lift(_ buf: RustBuffer) throws -> Expected {
    return try FfiConverterTypeExpected.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeExpected_lower(_ value: Expected) -> RustBuffer {
    return FfiConverterTypeExpected.lower(value)
}


/**
 * One capability answer and its source.
 */
public struct Flag {
    public var value: Tri
    public var source: FlagSource

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(value: Tri, source: FlagSource) {
        self.value = value
        self.source = source
    }
}



extension Flag: Equatable, Hashable {
    public static func ==(lhs: Flag, rhs: Flag) -> Bool {
        if lhs.value != rhs.value {
            return false
        }
        if lhs.source != rhs.source {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(value)
        hasher.combine(source)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeFlag: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Flag {
        return
            try Flag(
                value: FfiConverterTypeTri.read(from: &buf), 
                source: FfiConverterTypeFlagSource.read(from: &buf)
        )
    }

    public static func write(_ value: Flag, into buf: inout [UInt8]) {
        FfiConverterTypeTri.write(value.value, into: &buf)
        FfiConverterTypeFlagSource.write(value.source, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFlag_lift(_ buf: RustBuffer) throws -> Flag {
    return try FfiConverterTypeFlag.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFlag_lower(_ value: Flag) -> RustBuffer {
    return FfiConverterTypeFlag.lower(value)
}


/**
 * Where to reach GitHub and which OAuth app to use.
 */
public struct GitHubAuthConfig {
    /**
     * REST API base, `https://api.github.com` for github.com.
     */
    public var apiBaseUrl: String
    /**
     * Web base that serves `/login/device/code`, `https://github.com`.
     */
    public var webBaseUrl: String
    /**
     * OAuth app client id for the device flow. `None` keeps the flow
     * disabled (CLS-1343 tracks registering the app). Never hard-coded.
     */
    public var oauthClientId: String?

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(
        /**
         * REST API base, `https://api.github.com` for github.com.
         */apiBaseUrl: String, 
        /**
         * Web base that serves `/login/device/code`, `https://github.com`.
         */webBaseUrl: String, 
        /**
         * OAuth app client id for the device flow. `None` keeps the flow
         * disabled (CLS-1343 tracks registering the app). Never hard-coded.
         */oauthClientId: String?) {
        self.apiBaseUrl = apiBaseUrl
        self.webBaseUrl = webBaseUrl
        self.oauthClientId = oauthClientId
    }
}



extension GitHubAuthConfig: Equatable, Hashable {
    public static func ==(lhs: GitHubAuthConfig, rhs: GitHubAuthConfig) -> Bool {
        if lhs.apiBaseUrl != rhs.apiBaseUrl {
            return false
        }
        if lhs.webBaseUrl != rhs.webBaseUrl {
            return false
        }
        if lhs.oauthClientId != rhs.oauthClientId {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(apiBaseUrl)
        hasher.combine(webBaseUrl)
        hasher.combine(oauthClientId)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeGitHubAuthConfig: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> GitHubAuthConfig {
        return
            try GitHubAuthConfig(
                apiBaseUrl: FfiConverterString.read(from: &buf), 
                webBaseUrl: FfiConverterString.read(from: &buf), 
                oauthClientId: FfiConverterOptionString.read(from: &buf)
        )
    }

    public static func write(_ value: GitHubAuthConfig, into buf: inout [UInt8]) {
        FfiConverterString.write(value.apiBaseUrl, into: &buf)
        FfiConverterString.write(value.webBaseUrl, into: &buf)
        FfiConverterOptionString.write(value.oauthClientId, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeGitHubAuthConfig_lift(_ buf: RustBuffer) throws -> GitHubAuthConfig {
    return try FfiConverterTypeGitHubAuthConfig.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeGitHubAuthConfig_lower(_ value: GitHubAuthConfig) -> RustBuffer {
    return FfiConverterTypeGitHubAuthConfig.lower(value)
}


/**
 * The signed-in principal, as read from the provider.
 */
public struct Identity {
    public var provider: String
    public var instance: String
    /**
     * The provider's own id, kept as a string so every provider fits.
     */
    public var sourceId: String
    public var login: String
    /**
     * Empty when the provider has no display name for this principal.
     */
    public var displayName: String
    public var avatarUrl: String
    public var kind: IdentityKind

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(provider: String, instance: String, 
        /**
         * The provider's own id, kept as a string so every provider fits.
         */sourceId: String, login: String, 
        /**
         * Empty when the provider has no display name for this principal.
         */displayName: String, avatarUrl: String, kind: IdentityKind) {
        self.provider = provider
        self.instance = instance
        self.sourceId = sourceId
        self.login = login
        self.displayName = displayName
        self.avatarUrl = avatarUrl
        self.kind = kind
    }
}



extension Identity: Equatable, Hashable {
    public static func ==(lhs: Identity, rhs: Identity) -> Bool {
        if lhs.provider != rhs.provider {
            return false
        }
        if lhs.instance != rhs.instance {
            return false
        }
        if lhs.sourceId != rhs.sourceId {
            return false
        }
        if lhs.login != rhs.login {
            return false
        }
        if lhs.displayName != rhs.displayName {
            return false
        }
        if lhs.avatarUrl != rhs.avatarUrl {
            return false
        }
        if lhs.kind != rhs.kind {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(provider)
        hasher.combine(instance)
        hasher.combine(sourceId)
        hasher.combine(login)
        hasher.combine(displayName)
        hasher.combine(avatarUrl)
        hasher.combine(kind)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeIdentity: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Identity {
        return
            try Identity(
                provider: FfiConverterString.read(from: &buf), 
                instance: FfiConverterString.read(from: &buf), 
                sourceId: FfiConverterString.read(from: &buf), 
                login: FfiConverterString.read(from: &buf), 
                displayName: FfiConverterString.read(from: &buf), 
                avatarUrl: FfiConverterString.read(from: &buf), 
                kind: FfiConverterTypeIdentityKind.read(from: &buf)
        )
    }

    public static func write(_ value: Identity, into buf: inout [UInt8]) {
        FfiConverterString.write(value.provider, into: &buf)
        FfiConverterString.write(value.instance, into: &buf)
        FfiConverterString.write(value.sourceId, into: &buf)
        FfiConverterString.write(value.login, into: &buf)
        FfiConverterString.write(value.displayName, into: &buf)
        FfiConverterString.write(value.avatarUrl, into: &buf)
        FfiConverterTypeIdentityKind.write(value.kind, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeIdentity_lift(_ buf: RustBuffer) throws -> Identity {
    return try FfiConverterTypeIdentity.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeIdentity_lower(_ value: Identity) -> RustBuffer {
    return FfiConverterTypeIdentity.lower(value)
}


/**
 * An issue.
 */
public struct Issue {
    public var id: Int64
    /**
     * Per-repo issue number.
     */
    public var number: Int64
    public var title: String
    public var body: String
    public var state: WorkItemState
    public var author: User
    public var labels: [Label]
    public var commentCount: Int64
    public var createdAt: String
    public var updatedAt: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(id: Int64, 
        /**
         * Per-repo issue number.
         */number: Int64, title: String, body: String, state: WorkItemState, author: User, labels: [Label], commentCount: Int64, createdAt: String, updatedAt: String) {
        self.id = id
        self.number = number
        self.title = title
        self.body = body
        self.state = state
        self.author = author
        self.labels = labels
        self.commentCount = commentCount
        self.createdAt = createdAt
        self.updatedAt = updatedAt
    }
}



extension Issue: Equatable, Hashable {
    public static func ==(lhs: Issue, rhs: Issue) -> Bool {
        if lhs.id != rhs.id {
            return false
        }
        if lhs.number != rhs.number {
            return false
        }
        if lhs.title != rhs.title {
            return false
        }
        if lhs.body != rhs.body {
            return false
        }
        if lhs.state != rhs.state {
            return false
        }
        if lhs.author != rhs.author {
            return false
        }
        if lhs.labels != rhs.labels {
            return false
        }
        if lhs.commentCount != rhs.commentCount {
            return false
        }
        if lhs.createdAt != rhs.createdAt {
            return false
        }
        if lhs.updatedAt != rhs.updatedAt {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(id)
        hasher.combine(number)
        hasher.combine(title)
        hasher.combine(body)
        hasher.combine(state)
        hasher.combine(author)
        hasher.combine(labels)
        hasher.combine(commentCount)
        hasher.combine(createdAt)
        hasher.combine(updatedAt)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeIssue: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Issue {
        return
            try Issue(
                id: FfiConverterInt64.read(from: &buf), 
                number: FfiConverterInt64.read(from: &buf), 
                title: FfiConverterString.read(from: &buf), 
                body: FfiConverterString.read(from: &buf), 
                state: FfiConverterTypeWorkItemState.read(from: &buf), 
                author: FfiConverterTypeUser.read(from: &buf), 
                labels: FfiConverterSequenceTypeLabel.read(from: &buf), 
                commentCount: FfiConverterInt64.read(from: &buf), 
                createdAt: FfiConverterString.read(from: &buf), 
                updatedAt: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: Issue, into buf: inout [UInt8]) {
        FfiConverterInt64.write(value.id, into: &buf)
        FfiConverterInt64.write(value.number, into: &buf)
        FfiConverterString.write(value.title, into: &buf)
        FfiConverterString.write(value.body, into: &buf)
        FfiConverterTypeWorkItemState.write(value.state, into: &buf)
        FfiConverterTypeUser.write(value.author, into: &buf)
        FfiConverterSequenceTypeLabel.write(value.labels, into: &buf)
        FfiConverterInt64.write(value.commentCount, into: &buf)
        FfiConverterString.write(value.createdAt, into: &buf)
        FfiConverterString.write(value.updatedAt, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeIssue_lift(_ buf: RustBuffer) throws -> Issue {
    return try FfiConverterTypeIssue.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeIssue_lower(_ value: Issue) -> RustBuffer {
    return FfiConverterTypeIssue.lower(value)
}


/**
 * An issue a stack tracks.
 */
public struct IssueRef {
    public var number: Int64
    public var title: String?
    public var url: String?

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(number: Int64, title: String?, url: String?) {
        self.number = number
        self.title = title
        self.url = url
    }
}



extension IssueRef: Equatable, Hashable {
    public static func ==(lhs: IssueRef, rhs: IssueRef) -> Bool {
        if lhs.number != rhs.number {
            return false
        }
        if lhs.title != rhs.title {
            return false
        }
        if lhs.url != rhs.url {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(number)
        hasher.combine(title)
        hasher.combine(url)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeIssueRef: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IssueRef {
        return
            try IssueRef(
                number: FfiConverterInt64.read(from: &buf), 
                title: FfiConverterOptionString.read(from: &buf), 
                url: FfiConverterOptionString.read(from: &buf)
        )
    }

    public static func write(_ value: IssueRef, into buf: inout [UInt8]) {
        FfiConverterInt64.write(value.number, into: &buf)
        FfiConverterOptionString.write(value.title, into: &buf)
        FfiConverterOptionString.write(value.url, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeIssueRef_lift(_ buf: RustBuffer) throws -> IssueRef {
    return try FfiConverterTypeIssueRef.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeIssueRef_lower(_ value: IssueRef) -> RustBuffer {
    return FfiConverterTypeIssueRef.lower(value)
}


/**
 * A typed, provider-owned edge, for example `closes` or `blocked_by`.
 */
public struct ItemLink {
    /**
     * The provider's relation name, verbatim.
     */
    public var relation: String
    public var target: ItemRef

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(
        /**
         * The provider's relation name, verbatim.
         */relation: String, target: ItemRef) {
        self.relation = relation
        self.target = target
    }
}



extension ItemLink: Equatable, Hashable {
    public static func ==(lhs: ItemLink, rhs: ItemLink) -> Bool {
        if lhs.relation != rhs.relation {
            return false
        }
        if lhs.target != rhs.target {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(relation)
        hasher.combine(target)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeItemLink: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ItemLink {
        return
            try ItemLink(
                relation: FfiConverterString.read(from: &buf), 
                target: FfiConverterTypeItemRef.read(from: &buf)
        )
    }

    public static func write(_ value: ItemLink, into buf: inout [UInt8]) {
        FfiConverterString.write(value.relation, into: &buf)
        FfiConverterTypeItemRef.write(value.target, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeItemLink_lift(_ buf: RustBuffer) throws -> ItemLink {
    return try FfiConverterTypeItemLink.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeItemLink_lower(_ value: ItemLink) -> RustBuffer {
    return FfiConverterTypeItemLink.lower(value)
}


/**
 * The PR backing a stack item, once opened.
 */
public struct ItemPr {
    public var number: Int64
    public var url: String
    public var state: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(number: Int64, url: String, state: String) {
        self.number = number
        self.url = url
        self.state = state
    }
}



extension ItemPr: Equatable, Hashable {
    public static func ==(lhs: ItemPr, rhs: ItemPr) -> Bool {
        if lhs.number != rhs.number {
            return false
        }
        if lhs.url != rhs.url {
            return false
        }
        if lhs.state != rhs.state {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(number)
        hasher.combine(url)
        hasher.combine(state)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeItemPr: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ItemPr {
        return
            try ItemPr(
                number: FfiConverterInt64.read(from: &buf), 
                url: FfiConverterString.read(from: &buf), 
                state: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: ItemPr, into buf: inout [UInt8]) {
        FfiConverterInt64.write(value.number, into: &buf)
        FfiConverterString.write(value.url, into: &buf)
        FfiConverterString.write(value.state, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeItemPr_lift(_ buf: RustBuffer) throws -> ItemPr {
    return try FfiConverterTypeItemPr.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeItemPr_lower(_ value: ItemPr) -> RustBuffer {
    return FfiConverterTypeItemPr.lower(value)
}


/**
 * A reference to one provider object. `locator` is written by the adapter
 * that produced the ref and read back only by that adapter; shells store and
 * pass it back, they never parse it.
 */
public struct ItemRef {
    public var provider: ProviderKind
    public var instance: String
    public var kind: ItemKind
    /**
     * The provider's own id, as a string so every provider fits.
     */
    public var sourceId: String
    /**
     * Adapter-private address, for example `owner/repo#12`.
     */
    public var locator: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(provider: ProviderKind, instance: String, kind: ItemKind, 
        /**
         * The provider's own id, as a string so every provider fits.
         */sourceId: String, 
        /**
         * Adapter-private address, for example `owner/repo#12`.
         */locator: String) {
        self.provider = provider
        self.instance = instance
        self.kind = kind
        self.sourceId = sourceId
        self.locator = locator
    }
}



extension ItemRef: Equatable, Hashable {
    public static func ==(lhs: ItemRef, rhs: ItemRef) -> Bool {
        if lhs.provider != rhs.provider {
            return false
        }
        if lhs.instance != rhs.instance {
            return false
        }
        if lhs.kind != rhs.kind {
            return false
        }
        if lhs.sourceId != rhs.sourceId {
            return false
        }
        if lhs.locator != rhs.locator {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(provider)
        hasher.combine(instance)
        hasher.combine(kind)
        hasher.combine(sourceId)
        hasher.combine(locator)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeItemRef: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ItemRef {
        return
            try ItemRef(
                provider: FfiConverterTypeProviderKind.read(from: &buf), 
                instance: FfiConverterString.read(from: &buf), 
                kind: FfiConverterTypeItemKind.read(from: &buf), 
                sourceId: FfiConverterString.read(from: &buf), 
                locator: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: ItemRef, into buf: inout [UInt8]) {
        FfiConverterTypeProviderKind.write(value.provider, into: &buf)
        FfiConverterString.write(value.instance, into: &buf)
        FfiConverterTypeItemKind.write(value.kind, into: &buf)
        FfiConverterString.write(value.sourceId, into: &buf)
        FfiConverterString.write(value.locator, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeItemRef_lift(_ buf: RustBuffer) throws -> ItemRef {
    return try FfiConverterTypeItemRef.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeItemRef_lower(_ value: ItemRef) -> RustBuffer {
    return FfiConverterTypeItemRef.lower(value)
}


/**
 * A label.
 */
public struct Label {
    public var id: Int64
    public var name: String
    /**
     * Hex color without the leading `#`.
     */
    public var color: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(id: Int64, name: String, 
        /**
         * Hex color without the leading `#`.
         */color: String) {
        self.id = id
        self.name = name
        self.color = color
    }
}



extension Label: Equatable, Hashable {
    public static func ==(lhs: Label, rhs: Label) -> Bool {
        if lhs.id != rhs.id {
            return false
        }
        if lhs.name != rhs.name {
            return false
        }
        if lhs.color != rhs.color {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(id)
        hasher.combine(name)
        hasher.combine(color)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeLabel: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Label {
        return
            try Label(
                id: FfiConverterInt64.read(from: &buf), 
                name: FfiConverterString.read(from: &buf), 
                color: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: Label, into buf: inout [UInt8]) {
        FfiConverterInt64.write(value.id, into: &buf)
        FfiConverterString.write(value.name, into: &buf)
        FfiConverterString.write(value.color, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeLabel_lift(_ buf: RustBuffer) throws -> Label {
    return try FfiConverterTypeLabel.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeLabel_lower(_ value: Label) -> RustBuffer {
    return FfiConverterTypeLabel.lower(value)
}


/**
 * A label, keeping the provider id.
 */
public struct LabelRef {
    public var name: String
    public var sourceId: String
    /**
     * Hex colour without `#`, empty when the provider has none.
     */
    public var color: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(name: String, sourceId: String, 
        /**
         * Hex colour without `#`, empty when the provider has none.
         */color: String) {
        self.name = name
        self.sourceId = sourceId
        self.color = color
    }
}



extension LabelRef: Equatable, Hashable {
    public static func ==(lhs: LabelRef, rhs: LabelRef) -> Bool {
        if lhs.name != rhs.name {
            return false
        }
        if lhs.sourceId != rhs.sourceId {
            return false
        }
        if lhs.color != rhs.color {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(name)
        hasher.combine(sourceId)
        hasher.combine(color)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeLabelRef: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> LabelRef {
        return
            try LabelRef(
                name: FfiConverterString.read(from: &buf), 
                sourceId: FfiConverterString.read(from: &buf), 
                color: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: LabelRef, into buf: inout [UInt8]) {
        FfiConverterString.write(value.name, into: &buf)
        FfiConverterString.write(value.sourceId, into: &buf)
        FfiConverterString.write(value.color, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeLabelRef_lift(_ buf: RustBuffer) throws -> LabelRef {
    return try FfiConverterTypeLabelRef.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeLabelRef_lower(_ value: LabelRef) -> RustBuffer {
    return FfiConverterTypeLabelRef.lower(value)
}


/**
 * Merge readiness kept as two facts, because providers disagree on whether
 * it is a value or derived (PLAT-777 `MergeReadiness`).
 */
public struct MergeReadiness {
    public var normalized: Readiness
    /**
     * The source fields verbatim, for example GitHub `mergeable` and
     * `mergeable_state`, or Forgejo `mergeable` and `user_can_merge`.
     */
    public var source: [String: String]
    /**
     * True when Fjord computed `normalized`.
     */
    public var derived: Bool

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(normalized: Readiness, 
        /**
         * The source fields verbatim, for example GitHub `mergeable` and
         * `mergeable_state`, or Forgejo `mergeable` and `user_can_merge`.
         */source: [String: String], 
        /**
         * True when Fjord computed `normalized`.
         */derived: Bool) {
        self.normalized = normalized
        self.source = source
        self.derived = derived
    }
}



extension MergeReadiness: Equatable, Hashable {
    public static func ==(lhs: MergeReadiness, rhs: MergeReadiness) -> Bool {
        if lhs.normalized != rhs.normalized {
            return false
        }
        if lhs.source != rhs.source {
            return false
        }
        if lhs.derived != rhs.derived {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(normalized)
        hasher.combine(source)
        hasher.combine(derived)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeMergeReadiness: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MergeReadiness {
        return
            try MergeReadiness(
                normalized: FfiConverterTypeReadiness.read(from: &buf), 
                source: FfiConverterDictionaryStringString.read(from: &buf), 
                derived: FfiConverterBool.read(from: &buf)
        )
    }

    public static func write(_ value: MergeReadiness, into buf: inout [UInt8]) {
        FfiConverterTypeReadiness.write(value.normalized, into: &buf)
        FfiConverterDictionaryStringString.write(value.source, into: &buf)
        FfiConverterBool.write(value.derived, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeMergeReadiness_lift(_ buf: RustBuffer) throws -> MergeReadiness {
    return try FfiConverterTypeMergeReadiness.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeMergeReadiness_lower(_ value: MergeReadiness) -> RustBuffer {
    return FfiConverterTypeMergeReadiness.lower(value)
}


/**
 * An inbox notification.
 */
public struct Notification {
    public var id: Int64
    public var title: String
    /**
     * Subject kind as Forgejo reports it (e.g. `Issue`, `Pull`, `Commit`).
     */
    public var subjectKind: String
    public var repositoryFullName: String
    public var unread: Bool
    public var updatedAt: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(id: Int64, title: String, 
        /**
         * Subject kind as Forgejo reports it (e.g. `Issue`, `Pull`, `Commit`).
         */subjectKind: String, repositoryFullName: String, unread: Bool, updatedAt: String) {
        self.id = id
        self.title = title
        self.subjectKind = subjectKind
        self.repositoryFullName = repositoryFullName
        self.unread = unread
        self.updatedAt = updatedAt
    }
}



extension Notification: Equatable, Hashable {
    public static func ==(lhs: Notification, rhs: Notification) -> Bool {
        if lhs.id != rhs.id {
            return false
        }
        if lhs.title != rhs.title {
            return false
        }
        if lhs.subjectKind != rhs.subjectKind {
            return false
        }
        if lhs.repositoryFullName != rhs.repositoryFullName {
            return false
        }
        if lhs.unread != rhs.unread {
            return false
        }
        if lhs.updatedAt != rhs.updatedAt {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(id)
        hasher.combine(title)
        hasher.combine(subjectKind)
        hasher.combine(repositoryFullName)
        hasher.combine(unread)
        hasher.combine(updatedAt)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeNotification: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Notification {
        return
            try Notification(
                id: FfiConverterInt64.read(from: &buf), 
                title: FfiConverterString.read(from: &buf), 
                subjectKind: FfiConverterString.read(from: &buf), 
                repositoryFullName: FfiConverterString.read(from: &buf), 
                unread: FfiConverterBool.read(from: &buf), 
                updatedAt: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: Notification, into buf: inout [UInt8]) {
        FfiConverterInt64.write(value.id, into: &buf)
        FfiConverterString.write(value.title, into: &buf)
        FfiConverterString.write(value.subjectKind, into: &buf)
        FfiConverterString.write(value.repositoryFullName, into: &buf)
        FfiConverterBool.write(value.unread, into: &buf)
        FfiConverterString.write(value.updatedAt, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeNotification_lift(_ buf: RustBuffer) throws -> Notification {
    return try FfiConverterTypeNotification.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeNotification_lower(_ value: Notification) -> RustBuffer {
    return FfiConverterTypeNotification.lower(value)
}


/**
 * An opaque continuation token. Adapters encode whatever they need (a page
 * number, a cursor, a URL); shells pass it back unchanged.
 */
public struct PageToken {
    public var value: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(value: String) {
        self.value = value
    }
}



extension PageToken: Equatable, Hashable {
    public static func ==(lhs: PageToken, rhs: PageToken) -> Bool {
        if lhs.value != rhs.value {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(value)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypePageToken: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PageToken {
        return
            try PageToken(
                value: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: PageToken, into buf: inout [UInt8]) {
        FfiConverterString.write(value.value, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePageToken_lift(_ buf: RustBuffer) throws -> PageToken {
    return try FfiConverterTypePageToken.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePageToken_lower(_ value: PageToken) -> RustBuffer {
    return FfiConverterTypePageToken.lower(value)
}


/**
 * What the provider actually said.
 */
public struct ProviderDetail {
    /**
     * HTTP status, when a response arrived.
     */
    public var status: UInt16?
    public var message: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(
        /**
         * HTTP status, when a response arrived.
         */status: UInt16?, message: String) {
        self.status = status
        self.message = message
    }
}



extension ProviderDetail: Equatable, Hashable {
    public static func ==(lhs: ProviderDetail, rhs: ProviderDetail) -> Bool {
        if lhs.status != rhs.status {
            return false
        }
        if lhs.message != rhs.message {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(status)
        hasher.combine(message)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeProviderDetail: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ProviderDetail {
        return
            try ProviderDetail(
                status: FfiConverterOptionUInt16.read(from: &buf), 
                message: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: ProviderDetail, into buf: inout [UInt8]) {
        FfiConverterOptionUInt16.write(value.status, into: &buf)
        FfiConverterString.write(value.message, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeProviderDetail_lift(_ buf: RustBuffer) throws -> ProviderDetail {
    return try FfiConverterTypeProviderDetail.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeProviderDetail_lower(_ value: ProviderDetail) -> RustBuffer {
    return FfiConverterTypeProviderDetail.lower(value)
}


/**
 * A pull request.
 */
public struct PullRequest {
    public var id: Int64
    public var number: Int64
    public var title: String
    public var body: String
    public var state: PullRequestState
    public var draft: Bool
    public var author: User
    public var baseBranch: String
    public var headBranch: String
    public var createdAt: String
    public var updatedAt: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(id: Int64, number: Int64, title: String, body: String, state: PullRequestState, draft: Bool, author: User, baseBranch: String, headBranch: String, createdAt: String, updatedAt: String) {
        self.id = id
        self.number = number
        self.title = title
        self.body = body
        self.state = state
        self.draft = draft
        self.author = author
        self.baseBranch = baseBranch
        self.headBranch = headBranch
        self.createdAt = createdAt
        self.updatedAt = updatedAt
    }
}



extension PullRequest: Equatable, Hashable {
    public static func ==(lhs: PullRequest, rhs: PullRequest) -> Bool {
        if lhs.id != rhs.id {
            return false
        }
        if lhs.number != rhs.number {
            return false
        }
        if lhs.title != rhs.title {
            return false
        }
        if lhs.body != rhs.body {
            return false
        }
        if lhs.state != rhs.state {
            return false
        }
        if lhs.draft != rhs.draft {
            return false
        }
        if lhs.author != rhs.author {
            return false
        }
        if lhs.baseBranch != rhs.baseBranch {
            return false
        }
        if lhs.headBranch != rhs.headBranch {
            return false
        }
        if lhs.createdAt != rhs.createdAt {
            return false
        }
        if lhs.updatedAt != rhs.updatedAt {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(id)
        hasher.combine(number)
        hasher.combine(title)
        hasher.combine(body)
        hasher.combine(state)
        hasher.combine(draft)
        hasher.combine(author)
        hasher.combine(baseBranch)
        hasher.combine(headBranch)
        hasher.combine(createdAt)
        hasher.combine(updatedAt)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypePullRequest: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PullRequest {
        return
            try PullRequest(
                id: FfiConverterInt64.read(from: &buf), 
                number: FfiConverterInt64.read(from: &buf), 
                title: FfiConverterString.read(from: &buf), 
                body: FfiConverterString.read(from: &buf), 
                state: FfiConverterTypePullRequestState.read(from: &buf), 
                draft: FfiConverterBool.read(from: &buf), 
                author: FfiConverterTypeUser.read(from: &buf), 
                baseBranch: FfiConverterString.read(from: &buf), 
                headBranch: FfiConverterString.read(from: &buf), 
                createdAt: FfiConverterString.read(from: &buf), 
                updatedAt: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: PullRequest, into buf: inout [UInt8]) {
        FfiConverterInt64.write(value.id, into: &buf)
        FfiConverterInt64.write(value.number, into: &buf)
        FfiConverterString.write(value.title, into: &buf)
        FfiConverterString.write(value.body, into: &buf)
        FfiConverterTypePullRequestState.write(value.state, into: &buf)
        FfiConverterBool.write(value.draft, into: &buf)
        FfiConverterTypeUser.write(value.author, into: &buf)
        FfiConverterString.write(value.baseBranch, into: &buf)
        FfiConverterString.write(value.headBranch, into: &buf)
        FfiConverterString.write(value.createdAt, into: &buf)
        FfiConverterString.write(value.updatedAt, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePullRequest_lift(_ buf: RustBuffer) throws -> PullRequest {
    return try FfiConverterTypePullRequest.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePullRequest_lower(_ value: PullRequest) -> RustBuffer {
    return FfiConverterTypePullRequest.lower(value)
}


/**
 * One repository the account can read.
 */
public struct Repo {
    public var envelope: Envelope
    public var repoRef: ItemRef
    /**
     * `owner/name`.
     */
    public var fullName: String
    public var description: String
    public var url: String
    public var defaultBranch: String
    public var `private`: Bool
    public var archived: Bool
    public var updatedAt: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(envelope: Envelope, repoRef: ItemRef, 
        /**
         * `owner/name`.
         */fullName: String, description: String, url: String, defaultBranch: String, `private`: Bool, archived: Bool, updatedAt: String) {
        self.envelope = envelope
        self.repoRef = repoRef
        self.fullName = fullName
        self.description = description
        self.url = url
        self.defaultBranch = defaultBranch
        self.`private` = `private`
        self.archived = archived
        self.updatedAt = updatedAt
    }
}



extension Repo: Equatable, Hashable {
    public static func ==(lhs: Repo, rhs: Repo) -> Bool {
        if lhs.envelope != rhs.envelope {
            return false
        }
        if lhs.repoRef != rhs.repoRef {
            return false
        }
        if lhs.fullName != rhs.fullName {
            return false
        }
        if lhs.description != rhs.description {
            return false
        }
        if lhs.url != rhs.url {
            return false
        }
        if lhs.defaultBranch != rhs.defaultBranch {
            return false
        }
        if lhs.`private` != rhs.`private` {
            return false
        }
        if lhs.archived != rhs.archived {
            return false
        }
        if lhs.updatedAt != rhs.updatedAt {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(envelope)
        hasher.combine(repoRef)
        hasher.combine(fullName)
        hasher.combine(description)
        hasher.combine(url)
        hasher.combine(defaultBranch)
        hasher.combine(`private`)
        hasher.combine(archived)
        hasher.combine(updatedAt)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeRepo: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Repo {
        return
            try Repo(
                envelope: FfiConverterTypeEnvelope.read(from: &buf), 
                repoRef: FfiConverterTypeItemRef.read(from: &buf), 
                fullName: FfiConverterString.read(from: &buf), 
                description: FfiConverterString.read(from: &buf), 
                url: FfiConverterString.read(from: &buf), 
                defaultBranch: FfiConverterString.read(from: &buf), 
                private: FfiConverterBool.read(from: &buf), 
                archived: FfiConverterBool.read(from: &buf), 
                updatedAt: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: Repo, into buf: inout [UInt8]) {
        FfiConverterTypeEnvelope.write(value.envelope, into: &buf)
        FfiConverterTypeItemRef.write(value.repoRef, into: &buf)
        FfiConverterString.write(value.fullName, into: &buf)
        FfiConverterString.write(value.description, into: &buf)
        FfiConverterString.write(value.url, into: &buf)
        FfiConverterString.write(value.defaultBranch, into: &buf)
        FfiConverterBool.write(value.`private`, into: &buf)
        FfiConverterBool.write(value.archived, into: &buf)
        FfiConverterString.write(value.updatedAt, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRepo_lift(_ buf: RustBuffer) throws -> Repo {
    return try FfiConverterTypeRepo.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRepo_lower(_ value: Repo) -> RustBuffer {
    return FfiConverterTypeRepo.lower(value)
}


/**
 * One page of repositories. Pass `next` back for the following page.
 */
public struct RepoPage {
    public var items: [Repo]
    /**
     * `None` on the last page.
     */
    public var next: PageToken?

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(items: [Repo], 
        /**
         * `None` on the last page.
         */next: PageToken?) {
        self.items = items
        self.next = next
    }
}



extension RepoPage: Equatable, Hashable {
    public static func ==(lhs: RepoPage, rhs: RepoPage) -> Bool {
        if lhs.items != rhs.items {
            return false
        }
        if lhs.next != rhs.next {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(items)
        hasher.combine(next)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeRepoPage: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RepoPage {
        return
            try RepoPage(
                items: FfiConverterSequenceTypeRepo.read(from: &buf), 
                next: FfiConverterOptionTypePageToken.read(from: &buf)
        )
    }

    public static func write(_ value: RepoPage, into buf: inout [UInt8]) {
        FfiConverterSequenceTypeRepo.write(value.items, into: &buf)
        FfiConverterOptionTypePageToken.write(value.next, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRepoPage_lift(_ buf: RustBuffer) throws -> RepoPage {
    return try FfiConverterTypeRepoPage.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRepoPage_lower(_ value: RepoPage) -> RustBuffer {
    return FfiConverterTypeRepoPage.lower(value)
}


/**
 * The repository a stack lives in.
 */
public struct RepoRef {
    public var path: String
    public var remote: String
    public var url: String
    public var host: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(path: String, remote: String, url: String, host: String) {
        self.path = path
        self.remote = remote
        self.url = url
        self.host = host
    }
}



extension RepoRef: Equatable, Hashable {
    public static func ==(lhs: RepoRef, rhs: RepoRef) -> Bool {
        if lhs.path != rhs.path {
            return false
        }
        if lhs.remote != rhs.remote {
            return false
        }
        if lhs.url != rhs.url {
            return false
        }
        if lhs.host != rhs.host {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(path)
        hasher.combine(remote)
        hasher.combine(url)
        hasher.combine(host)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeRepoRef: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RepoRef {
        return
            try RepoRef(
                path: FfiConverterString.read(from: &buf), 
                remote: FfiConverterString.read(from: &buf), 
                url: FfiConverterString.read(from: &buf), 
                host: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: RepoRef, into buf: inout [UInt8]) {
        FfiConverterString.write(value.path, into: &buf)
        FfiConverterString.write(value.remote, into: &buf)
        FfiConverterString.write(value.url, into: &buf)
        FfiConverterString.write(value.host, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRepoRef_lift(_ buf: RustBuffer) throws -> RepoRef {
    return try FfiConverterTypeRepoRef.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRepoRef_lower(_ value: RepoRef) -> RustBuffer {
    return FfiConverterTypeRepoRef.lower(value)
}


/**
 * A repository.
 */
public struct Repository {
    public var id: Int64
    public var owner: String
    public var name: String
    /**
     * `owner/name`.
     */
    public var fullName: String
    public var `private`: Bool
    public var description: String
    public var defaultBranch: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(id: Int64, owner: String, name: String, 
        /**
         * `owner/name`.
         */fullName: String, `private`: Bool, description: String, defaultBranch: String) {
        self.id = id
        self.owner = owner
        self.name = name
        self.fullName = fullName
        self.`private` = `private`
        self.description = description
        self.defaultBranch = defaultBranch
    }
}



extension Repository: Equatable, Hashable {
    public static func ==(lhs: Repository, rhs: Repository) -> Bool {
        if lhs.id != rhs.id {
            return false
        }
        if lhs.owner != rhs.owner {
            return false
        }
        if lhs.name != rhs.name {
            return false
        }
        if lhs.fullName != rhs.fullName {
            return false
        }
        if lhs.`private` != rhs.`private` {
            return false
        }
        if lhs.description != rhs.description {
            return false
        }
        if lhs.defaultBranch != rhs.defaultBranch {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(id)
        hasher.combine(owner)
        hasher.combine(name)
        hasher.combine(fullName)
        hasher.combine(`private`)
        hasher.combine(description)
        hasher.combine(defaultBranch)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeRepository: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Repository {
        return
            try Repository(
                id: FfiConverterInt64.read(from: &buf), 
                owner: FfiConverterString.read(from: &buf), 
                name: FfiConverterString.read(from: &buf), 
                fullName: FfiConverterString.read(from: &buf), 
                private: FfiConverterBool.read(from: &buf), 
                description: FfiConverterString.read(from: &buf), 
                defaultBranch: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: Repository, into buf: inout [UInt8]) {
        FfiConverterInt64.write(value.id, into: &buf)
        FfiConverterString.write(value.owner, into: &buf)
        FfiConverterString.write(value.name, into: &buf)
        FfiConverterString.write(value.fullName, into: &buf)
        FfiConverterBool.write(value.`private`, into: &buf)
        FfiConverterString.write(value.description, into: &buf)
        FfiConverterString.write(value.defaultBranch, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRepository_lift(_ buf: RustBuffer) throws -> Repository {
    return try FfiConverterTypeRepository.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRepository_lower(_ value: Repository) -> RustBuffer {
    return FfiConverterTypeRepository.lower(value)
}


/**
 * One submitted (or pending) review.
 */
public struct Review {
    public var envelope: Envelope
    public var changeRequestRef: ItemRef
    public var reviewer: Identity?
    public var state: ReviewState
    /**
     * The provider's own state value, verbatim.
     */
    public var sourceState: String
    public var body: String
    /**
     * The commit the review was left on.
     */
    public var commitSha: String?
    public var submittedAt: String?
    /**
     * `None` when the adapter could not tell.
     */
    public var stale: Bool?
    public var staleMethod: StaleMethod

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(envelope: Envelope, changeRequestRef: ItemRef, reviewer: Identity?, state: ReviewState, 
        /**
         * The provider's own state value, verbatim.
         */sourceState: String, body: String, 
        /**
         * The commit the review was left on.
         */commitSha: String?, submittedAt: String?, 
        /**
         * `None` when the adapter could not tell.
         */stale: Bool?, staleMethod: StaleMethod) {
        self.envelope = envelope
        self.changeRequestRef = changeRequestRef
        self.reviewer = reviewer
        self.state = state
        self.sourceState = sourceState
        self.body = body
        self.commitSha = commitSha
        self.submittedAt = submittedAt
        self.stale = stale
        self.staleMethod = staleMethod
    }
}



extension Review: Equatable, Hashable {
    public static func ==(lhs: Review, rhs: Review) -> Bool {
        if lhs.envelope != rhs.envelope {
            return false
        }
        if lhs.changeRequestRef != rhs.changeRequestRef {
            return false
        }
        if lhs.reviewer != rhs.reviewer {
            return false
        }
        if lhs.state != rhs.state {
            return false
        }
        if lhs.sourceState != rhs.sourceState {
            return false
        }
        if lhs.body != rhs.body {
            return false
        }
        if lhs.commitSha != rhs.commitSha {
            return false
        }
        if lhs.submittedAt != rhs.submittedAt {
            return false
        }
        if lhs.stale != rhs.stale {
            return false
        }
        if lhs.staleMethod != rhs.staleMethod {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(envelope)
        hasher.combine(changeRequestRef)
        hasher.combine(reviewer)
        hasher.combine(state)
        hasher.combine(sourceState)
        hasher.combine(body)
        hasher.combine(commitSha)
        hasher.combine(submittedAt)
        hasher.combine(stale)
        hasher.combine(staleMethod)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeReview: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Review {
        return
            try Review(
                envelope: FfiConverterTypeEnvelope.read(from: &buf), 
                changeRequestRef: FfiConverterTypeItemRef.read(from: &buf), 
                reviewer: FfiConverterOptionTypeIdentity.read(from: &buf), 
                state: FfiConverterTypeReviewState.read(from: &buf), 
                sourceState: FfiConverterString.read(from: &buf), 
                body: FfiConverterString.read(from: &buf), 
                commitSha: FfiConverterOptionString.read(from: &buf), 
                submittedAt: FfiConverterOptionString.read(from: &buf), 
                stale: FfiConverterOptionBool.read(from: &buf), 
                staleMethod: FfiConverterTypeStaleMethod.read(from: &buf)
        )
    }

    public static func write(_ value: Review, into buf: inout [UInt8]) {
        FfiConverterTypeEnvelope.write(value.envelope, into: &buf)
        FfiConverterTypeItemRef.write(value.changeRequestRef, into: &buf)
        FfiConverterOptionTypeIdentity.write(value.reviewer, into: &buf)
        FfiConverterTypeReviewState.write(value.state, into: &buf)
        FfiConverterString.write(value.sourceState, into: &buf)
        FfiConverterString.write(value.body, into: &buf)
        FfiConverterOptionString.write(value.commitSha, into: &buf)
        FfiConverterOptionString.write(value.submittedAt, into: &buf)
        FfiConverterOptionBool.write(value.stale, into: &buf)
        FfiConverterTypeStaleMethod.write(value.staleMethod, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeReview_lift(_ buf: RustBuffer) throws -> Review {
    return try FfiConverterTypeReview.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeReview_lower(_ value: Review) -> RustBuffer {
    return FfiConverterTypeReview.lower(value)
}


/**
 * An outstanding or past review request, as the source reports it.
 */
public struct ReviewRequest {
    public var changeRequestRef: ItemRef
    public var reviewer: Reviewer
    public var requestedAt: String?
    /**
     * Whether the provider still lists this reviewer as requested.
     */
    public var stillRequested: Bool

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(changeRequestRef: ItemRef, reviewer: Reviewer, requestedAt: String?, 
        /**
         * Whether the provider still lists this reviewer as requested.
         */stillRequested: Bool) {
        self.changeRequestRef = changeRequestRef
        self.reviewer = reviewer
        self.requestedAt = requestedAt
        self.stillRequested = stillRequested
    }
}



extension ReviewRequest: Equatable, Hashable {
    public static func ==(lhs: ReviewRequest, rhs: ReviewRequest) -> Bool {
        if lhs.changeRequestRef != rhs.changeRequestRef {
            return false
        }
        if lhs.reviewer != rhs.reviewer {
            return false
        }
        if lhs.requestedAt != rhs.requestedAt {
            return false
        }
        if lhs.stillRequested != rhs.stillRequested {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(changeRequestRef)
        hasher.combine(reviewer)
        hasher.combine(requestedAt)
        hasher.combine(stillRequested)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeReviewRequest: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ReviewRequest {
        return
            try ReviewRequest(
                changeRequestRef: FfiConverterTypeItemRef.read(from: &buf), 
                reviewer: FfiConverterTypeReviewer.read(from: &buf), 
                requestedAt: FfiConverterOptionString.read(from: &buf), 
                stillRequested: FfiConverterBool.read(from: &buf)
        )
    }

    public static func write(_ value: ReviewRequest, into buf: inout [UInt8]) {
        FfiConverterTypeItemRef.write(value.changeRequestRef, into: &buf)
        FfiConverterTypeReviewer.write(value.reviewer, into: &buf)
        FfiConverterOptionString.write(value.requestedAt, into: &buf)
        FfiConverterBool.write(value.stillRequested, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeReviewRequest_lift(_ buf: RustBuffer) throws -> ReviewRequest {
    return try FfiConverterTypeReviewRequest.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeReviewRequest_lower(_ value: ReviewRequest) -> RustBuffer {
    return FfiConverterTypeReviewRequest.lower(value)
}


/**
 * The rolled-up state. Always derived by Fjord.
 */
public struct Rollup {
    public var state: CheckState
    /**
     * The provider's combined value, verbatim (may be empty).
     */
    public var source: String
    public var derived: Bool
    /**
     * True when the provider reported no checks.
     */
    public var empty: Bool

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(state: CheckState, 
        /**
         * The provider's combined value, verbatim (may be empty).
         */source: String, derived: Bool, 
        /**
         * True when the provider reported no checks.
         */empty: Bool) {
        self.state = state
        self.source = source
        self.derived = derived
        self.empty = empty
    }
}



extension Rollup: Equatable, Hashable {
    public static func ==(lhs: Rollup, rhs: Rollup) -> Bool {
        if lhs.state != rhs.state {
            return false
        }
        if lhs.source != rhs.source {
            return false
        }
        if lhs.derived != rhs.derived {
            return false
        }
        if lhs.empty != rhs.empty {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(state)
        hasher.combine(source)
        hasher.combine(derived)
        hasher.combine(empty)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeRollup: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Rollup {
        return
            try Rollup(
                state: FfiConverterTypeCheckState.read(from: &buf), 
                source: FfiConverterString.read(from: &buf), 
                derived: FfiConverterBool.read(from: &buf), 
                empty: FfiConverterBool.read(from: &buf)
        )
    }

    public static func write(_ value: Rollup, into buf: inout [UInt8]) {
        FfiConverterTypeCheckState.write(value.state, into: &buf)
        FfiConverterString.write(value.source, into: &buf)
        FfiConverterBool.write(value.derived, into: &buf)
        FfiConverterBool.write(value.empty, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRollup_lift(_ buf: RustBuffer) throws -> Rollup {
    return try FfiConverterTypeRollup.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRollup_lower(_ value: Rollup) -> RustBuffer {
    return FfiConverterTypeRollup.lower(value)
}


/**
 * Which host and account a session targets.
 */
public struct Session {
    /**
     * API base, e.g. `https://code.example.com`.
     */
    public var host: String
    /**
     * The signed-in user.
     */
    public var user: User

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(
        /**
         * API base, e.g. `https://code.example.com`.
         */host: String, 
        /**
         * The signed-in user.
         */user: User) {
        self.host = host
        self.user = user
    }
}



extension Session: Equatable, Hashable {
    public static func ==(lhs: Session, rhs: Session) -> Bool {
        if lhs.host != rhs.host {
            return false
        }
        if lhs.user != rhs.user {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(host)
        hasher.combine(user)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeSession: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Session {
        return
            try Session(
                host: FfiConverterString.read(from: &buf), 
                user: FfiConverterTypeUser.read(from: &buf)
        )
    }

    public static func write(_ value: Session, into buf: inout [UInt8]) {
        FfiConverterString.write(value.host, into: &buf)
        FfiConverterTypeUser.write(value.user, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeSession_lift(_ buf: RustBuffer) throws -> Session {
    return try FfiConverterTypeSession.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeSession_lower(_ value: Session) -> RustBuffer {
    return FfiConverterTypeSession.lower(value)
}


/**
 * One merge a ship intends to perform, bottom-up. `Serialize` lets shells emit
 * the plan verbatim for a `--json` dry run.
 */
public struct ShipStep {
    public var branch: String
    public var base: String
    public var style: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(branch: String, base: String, style: String) {
        self.branch = branch
        self.base = base
        self.style = style
    }
}



extension ShipStep: Equatable, Hashable {
    public static func ==(lhs: ShipStep, rhs: ShipStep) -> Bool {
        if lhs.branch != rhs.branch {
            return false
        }
        if lhs.base != rhs.base {
            return false
        }
        if lhs.style != rhs.style {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(branch)
        hasher.combine(base)
        hasher.combine(style)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeShipStep: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ShipStep {
        return
            try ShipStep(
                branch: FfiConverterString.read(from: &buf), 
                base: FfiConverterString.read(from: &buf), 
                style: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: ShipStep, into buf: inout [UInt8]) {
        FfiConverterString.write(value.branch, into: &buf)
        FfiConverterString.write(value.base, into: &buf)
        FfiConverterString.write(value.style, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeShipStep_lift(_ buf: RustBuffer) throws -> ShipStep {
    return try FfiConverterTypeShipStep.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeShipStep_lower(_ value: ShipStep) -> RustBuffer {
    return FfiConverterTypeShipStep.lower(value)
}


/**
 * A stack of dependent pull requests.
 */
public struct Stack {
    public var version: UInt32
    public var id: String
    public var name: String
    public var slug: String
    public var repo: RepoRef
    /**
     * The branch the bottom of the stack targets.
     */
    public var base: String
    public var createdAt: String
    public var updatedAt: String
    public var issue: IssueRef?
    public var items: [StackItem]
    public var shippedAt: String?

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(version: UInt32, id: String, name: String, slug: String, repo: RepoRef, 
        /**
         * The branch the bottom of the stack targets.
         */base: String, createdAt: String, updatedAt: String, issue: IssueRef?, items: [StackItem], shippedAt: String?) {
        self.version = version
        self.id = id
        self.name = name
        self.slug = slug
        self.repo = repo
        self.base = base
        self.createdAt = createdAt
        self.updatedAt = updatedAt
        self.issue = issue
        self.items = items
        self.shippedAt = shippedAt
    }
}



extension Stack: Equatable, Hashable {
    public static func ==(lhs: Stack, rhs: Stack) -> Bool {
        if lhs.version != rhs.version {
            return false
        }
        if lhs.id != rhs.id {
            return false
        }
        if lhs.name != rhs.name {
            return false
        }
        if lhs.slug != rhs.slug {
            return false
        }
        if lhs.repo != rhs.repo {
            return false
        }
        if lhs.base != rhs.base {
            return false
        }
        if lhs.createdAt != rhs.createdAt {
            return false
        }
        if lhs.updatedAt != rhs.updatedAt {
            return false
        }
        if lhs.issue != rhs.issue {
            return false
        }
        if lhs.items != rhs.items {
            return false
        }
        if lhs.shippedAt != rhs.shippedAt {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(version)
        hasher.combine(id)
        hasher.combine(name)
        hasher.combine(slug)
        hasher.combine(repo)
        hasher.combine(base)
        hasher.combine(createdAt)
        hasher.combine(updatedAt)
        hasher.combine(issue)
        hasher.combine(items)
        hasher.combine(shippedAt)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeStack: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Stack {
        return
            try Stack(
                version: FfiConverterUInt32.read(from: &buf), 
                id: FfiConverterString.read(from: &buf), 
                name: FfiConverterString.read(from: &buf), 
                slug: FfiConverterString.read(from: &buf), 
                repo: FfiConverterTypeRepoRef.read(from: &buf), 
                base: FfiConverterString.read(from: &buf), 
                createdAt: FfiConverterString.read(from: &buf), 
                updatedAt: FfiConverterString.read(from: &buf), 
                issue: FfiConverterOptionTypeIssueRef.read(from: &buf), 
                items: FfiConverterSequenceTypeStackItem.read(from: &buf), 
                shippedAt: FfiConverterOptionString.read(from: &buf)
        )
    }

    public static func write(_ value: Stack, into buf: inout [UInt8]) {
        FfiConverterUInt32.write(value.version, into: &buf)
        FfiConverterString.write(value.id, into: &buf)
        FfiConverterString.write(value.name, into: &buf)
        FfiConverterString.write(value.slug, into: &buf)
        FfiConverterTypeRepoRef.write(value.repo, into: &buf)
        FfiConverterString.write(value.base, into: &buf)
        FfiConverterString.write(value.createdAt, into: &buf)
        FfiConverterString.write(value.updatedAt, into: &buf)
        FfiConverterOptionTypeIssueRef.write(value.issue, into: &buf)
        FfiConverterSequenceTypeStackItem.write(value.items, into: &buf)
        FfiConverterOptionString.write(value.shippedAt, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeStack_lift(_ buf: RustBuffer) throws -> Stack {
    return try FfiConverterTypeStack.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeStack_lower(_ value: Stack) -> RustBuffer {
    return FfiConverterTypeStack.lower(value)
}


/**
 * One pull request in the stack.
 */
public struct StackItem {
    public var id: String
    public var title: String
    public var branch: String
    public var base: String
    public var pr: ItemPr?
    public var status: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(id: String, title: String, branch: String, base: String, pr: ItemPr?, status: String) {
        self.id = id
        self.title = title
        self.branch = branch
        self.base = base
        self.pr = pr
        self.status = status
    }
}



extension StackItem: Equatable, Hashable {
    public static func ==(lhs: StackItem, rhs: StackItem) -> Bool {
        if lhs.id != rhs.id {
            return false
        }
        if lhs.title != rhs.title {
            return false
        }
        if lhs.branch != rhs.branch {
            return false
        }
        if lhs.base != rhs.base {
            return false
        }
        if lhs.pr != rhs.pr {
            return false
        }
        if lhs.status != rhs.status {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(id)
        hasher.combine(title)
        hasher.combine(branch)
        hasher.combine(base)
        hasher.combine(pr)
        hasher.combine(status)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeStackItem: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> StackItem {
        return
            try StackItem(
                id: FfiConverterString.read(from: &buf), 
                title: FfiConverterString.read(from: &buf), 
                branch: FfiConverterString.read(from: &buf), 
                base: FfiConverterString.read(from: &buf), 
                pr: FfiConverterOptionTypeItemPr.read(from: &buf), 
                status: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: StackItem, into buf: inout [UInt8]) {
        FfiConverterString.write(value.id, into: &buf)
        FfiConverterString.write(value.title, into: &buf)
        FfiConverterString.write(value.branch, into: &buf)
        FfiConverterString.write(value.base, into: &buf)
        FfiConverterOptionTypeItemPr.write(value.pr, into: &buf)
        FfiConverterString.write(value.status, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeStackItem_lift(_ buf: RustBuffer) throws -> StackItem {
    return try FfiConverterTypeStackItem.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeStackItem_lower(_ value: StackItem) -> RustBuffer {
    return FfiConverterTypeStackItem.lower(value)
}


/**
 * One push-and-PR a sync intends to perform, bottom-up. `Serialize` lets shells
 * emit the plan verbatim for a `--json` dry run.
 */
public struct SyncStep {
    public var branch: String
    public var base: String
    public var title: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(branch: String, base: String, title: String) {
        self.branch = branch
        self.base = base
        self.title = title
    }
}



extension SyncStep: Equatable, Hashable {
    public static func ==(lhs: SyncStep, rhs: SyncStep) -> Bool {
        if lhs.branch != rhs.branch {
            return false
        }
        if lhs.base != rhs.base {
            return false
        }
        if lhs.title != rhs.title {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(branch)
        hasher.combine(base)
        hasher.combine(title)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeSyncStep: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SyncStep {
        return
            try SyncStep(
                branch: FfiConverterString.read(from: &buf), 
                base: FfiConverterString.read(from: &buf), 
                title: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: SyncStep, into buf: inout [UInt8]) {
        FfiConverterString.write(value.branch, into: &buf)
        FfiConverterString.write(value.base, into: &buf)
        FfiConverterString.write(value.title, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeSyncStep_lift(_ buf: RustBuffer) throws -> SyncStep {
    return try FfiConverterTypeSyncStep.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeSyncStep_lower(_ value: SyncStep) -> RustBuffer {
    return FfiConverterTypeSyncStep.lower(value)
}


/**
 * A team that can be asked for review (GitHub teams, Forgejo/Gitea teams).
 */
public struct TeamRef {
    public var sourceId: String
    /**
     * `org/team-slug` or the provider's equivalent.
     */
    public var slug: String
    public var name: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(sourceId: String, 
        /**
         * `org/team-slug` or the provider's equivalent.
         */slug: String, name: String) {
        self.sourceId = sourceId
        self.slug = slug
        self.name = name
    }
}



extension TeamRef: Equatable, Hashable {
    public static func ==(lhs: TeamRef, rhs: TeamRef) -> Bool {
        if lhs.sourceId != rhs.sourceId {
            return false
        }
        if lhs.slug != rhs.slug {
            return false
        }
        if lhs.name != rhs.name {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(sourceId)
        hasher.combine(slug)
        hasher.combine(name)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeTeamRef: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TeamRef {
        return
            try TeamRef(
                sourceId: FfiConverterString.read(from: &buf), 
                slug: FfiConverterString.read(from: &buf), 
                name: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: TeamRef, into buf: inout [UInt8]) {
        FfiConverterString.write(value.sourceId, into: &buf)
        FfiConverterString.write(value.slug, into: &buf)
        FfiConverterString.write(value.name, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeTeamRef_lift(_ buf: RustBuffer) throws -> TeamRef {
    return try FfiConverterTypeTeamRef.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeTeamRef_lower(_ value: TeamRef) -> RustBuffer {
    return FfiConverterTypeTeamRef.lower(value)
}


/**
 * Unresolved review-thread count for a change request.
 */
public struct ThreadState {
    public var changeRequestRef: ItemRef
    /**
     * `None` with `ThreadMethod::Unavailable` is legal.
     */
    public var unresolvedCount: UInt32?
    public var method: ThreadMethod

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(changeRequestRef: ItemRef, 
        /**
         * `None` with `ThreadMethod::Unavailable` is legal.
         */unresolvedCount: UInt32?, method: ThreadMethod) {
        self.changeRequestRef = changeRequestRef
        self.unresolvedCount = unresolvedCount
        self.method = method
    }
}



extension ThreadState: Equatable, Hashable {
    public static func ==(lhs: ThreadState, rhs: ThreadState) -> Bool {
        if lhs.changeRequestRef != rhs.changeRequestRef {
            return false
        }
        if lhs.unresolvedCount != rhs.unresolvedCount {
            return false
        }
        if lhs.method != rhs.method {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(changeRequestRef)
        hasher.combine(unresolvedCount)
        hasher.combine(method)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeThreadState: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ThreadState {
        return
            try ThreadState(
                changeRequestRef: FfiConverterTypeItemRef.read(from: &buf), 
                unresolvedCount: FfiConverterOptionUInt32.read(from: &buf), 
                method: FfiConverterTypeThreadMethod.read(from: &buf)
        )
    }

    public static func write(_ value: ThreadState, into buf: inout [UInt8]) {
        FfiConverterTypeItemRef.write(value.changeRequestRef, into: &buf)
        FfiConverterOptionUInt32.write(value.unresolvedCount, into: &buf)
        FfiConverterTypeThreadMethod.write(value.method, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeThreadState_lift(_ buf: RustBuffer) throws -> ThreadState {
    return try FfiConverterTypeThreadState.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeThreadState_lower(_ value: ThreadState) -> RustBuffer {
    return FfiConverterTypeThreadState.lower(value)
}


/**
 * What `GET /user` says about a token.
 */
public struct TokenValidation {
    public var identity: Identity
    public var tokenKind: TokenKind
    /**
     * GitHub's `github-authentication-token-expiration` header verbatim, or
     * `None` when the token does not expire or GitHub did not say.
     */
    public var expiresAt: String?
    public var access: AccessCheck

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(identity: Identity, tokenKind: TokenKind, 
        /**
         * GitHub's `github-authentication-token-expiration` header verbatim, or
         * `None` when the token does not expire or GitHub did not say.
         */expiresAt: String?, access: AccessCheck) {
        self.identity = identity
        self.tokenKind = tokenKind
        self.expiresAt = expiresAt
        self.access = access
    }
}



extension TokenValidation: Equatable, Hashable {
    public static func ==(lhs: TokenValidation, rhs: TokenValidation) -> Bool {
        if lhs.identity != rhs.identity {
            return false
        }
        if lhs.tokenKind != rhs.tokenKind {
            return false
        }
        if lhs.expiresAt != rhs.expiresAt {
            return false
        }
        if lhs.access != rhs.access {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(identity)
        hasher.combine(tokenKind)
        hasher.combine(expiresAt)
        hasher.combine(access)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeTokenValidation: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TokenValidation {
        return
            try TokenValidation(
                identity: FfiConverterTypeIdentity.read(from: &buf), 
                tokenKind: FfiConverterTypeTokenKind.read(from: &buf), 
                expiresAt: FfiConverterOptionString.read(from: &buf), 
                access: FfiConverterTypeAccessCheck.read(from: &buf)
        )
    }

    public static func write(_ value: TokenValidation, into buf: inout [UInt8]) {
        FfiConverterTypeIdentity.write(value.identity, into: &buf)
        FfiConverterTypeTokenKind.write(value.tokenKind, into: &buf)
        FfiConverterOptionString.write(value.expiresAt, into: &buf)
        FfiConverterTypeAccessCheck.write(value.access, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeTokenValidation_lift(_ buf: RustBuffer) throws -> TokenValidation {
    return try FfiConverterTypeTokenValidation.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeTokenValidation_lower(_ value: TokenValidation) -> RustBuffer {
    return FfiConverterTypeTokenValidation.lower(value)
}


/**
 * A user or organization account.
 */
public struct User {
    public var id: Int64
    public var login: String
    /**
     * Display name (full name when set, otherwise the login).
     */
    public var displayName: String
    public var avatarUrl: String

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(id: Int64, login: String, 
        /**
         * Display name (full name when set, otherwise the login).
         */displayName: String, avatarUrl: String) {
        self.id = id
        self.login = login
        self.displayName = displayName
        self.avatarUrl = avatarUrl
    }
}



extension User: Equatable, Hashable {
    public static func ==(lhs: User, rhs: User) -> Bool {
        if lhs.id != rhs.id {
            return false
        }
        if lhs.login != rhs.login {
            return false
        }
        if lhs.displayName != rhs.displayName {
            return false
        }
        if lhs.avatarUrl != rhs.avatarUrl {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(id)
        hasher.combine(login)
        hasher.combine(displayName)
        hasher.combine(avatarUrl)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeUser: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> User {
        return
            try User(
                id: FfiConverterInt64.read(from: &buf), 
                login: FfiConverterString.read(from: &buf), 
                displayName: FfiConverterString.read(from: &buf), 
                avatarUrl: FfiConverterString.read(from: &buf)
        )
    }

    public static func write(_ value: User, into buf: inout [UInt8]) {
        FfiConverterInt64.write(value.id, into: &buf)
        FfiConverterString.write(value.login, into: &buf)
        FfiConverterString.write(value.displayName, into: &buf)
        FfiConverterString.write(value.avatarUrl, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeUser_lift(_ buf: RustBuffer) throws -> User {
    return try FfiConverterTypeUser.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeUser_lower(_ value: User) -> RustBuffer {
    return FfiConverterTypeUser.lower(value)
}


/**
 * An issue, change request, milestone or container.
 */
public struct WorkItem {
    public var envelope: Envelope
    public var itemRef: ItemRef
    public var kind: WorkItemKind
    /**
     * The human number (`#12`) where the provider has one.
     */
    public var number: UInt64?
    public var title: String
    public var url: String
    public var body: String
    public var state: ItemState
    /**
     * The provider's own state value, verbatim.
     */
    public var stateSource: String
    public var author: Identity?
    public var assignees: [Identity]
    public var labels: [LabelRef]
    public var links: [ItemLink]
    public var parentRef: ItemRef?
    public var createdAt: String
    public var updatedAt: String
    /**
     * Unmodelled source fields, verbatim, keyed `<provider>.<field>`.
     */
    public var extras: [String: String]

    // Default memberwise initializers are never public by default, so we
    // declare one manually.
    public init(envelope: Envelope, itemRef: ItemRef, kind: WorkItemKind, 
        /**
         * The human number (`#12`) where the provider has one.
         */number: UInt64?, title: String, url: String, body: String, state: ItemState, 
        /**
         * The provider's own state value, verbatim.
         */stateSource: String, author: Identity?, assignees: [Identity], labels: [LabelRef], links: [ItemLink], parentRef: ItemRef?, createdAt: String, updatedAt: String, 
        /**
         * Unmodelled source fields, verbatim, keyed `<provider>.<field>`.
         */extras: [String: String]) {
        self.envelope = envelope
        self.itemRef = itemRef
        self.kind = kind
        self.number = number
        self.title = title
        self.url = url
        self.body = body
        self.state = state
        self.stateSource = stateSource
        self.author = author
        self.assignees = assignees
        self.labels = labels
        self.links = links
        self.parentRef = parentRef
        self.createdAt = createdAt
        self.updatedAt = updatedAt
        self.extras = extras
    }
}



extension WorkItem: Equatable, Hashable {
    public static func ==(lhs: WorkItem, rhs: WorkItem) -> Bool {
        if lhs.envelope != rhs.envelope {
            return false
        }
        if lhs.itemRef != rhs.itemRef {
            return false
        }
        if lhs.kind != rhs.kind {
            return false
        }
        if lhs.number != rhs.number {
            return false
        }
        if lhs.title != rhs.title {
            return false
        }
        if lhs.url != rhs.url {
            return false
        }
        if lhs.body != rhs.body {
            return false
        }
        if lhs.state != rhs.state {
            return false
        }
        if lhs.stateSource != rhs.stateSource {
            return false
        }
        if lhs.author != rhs.author {
            return false
        }
        if lhs.assignees != rhs.assignees {
            return false
        }
        if lhs.labels != rhs.labels {
            return false
        }
        if lhs.links != rhs.links {
            return false
        }
        if lhs.parentRef != rhs.parentRef {
            return false
        }
        if lhs.createdAt != rhs.createdAt {
            return false
        }
        if lhs.updatedAt != rhs.updatedAt {
            return false
        }
        if lhs.extras != rhs.extras {
            return false
        }
        return true
    }

    public func hash(into hasher: inout Hasher) {
        hasher.combine(envelope)
        hasher.combine(itemRef)
        hasher.combine(kind)
        hasher.combine(number)
        hasher.combine(title)
        hasher.combine(url)
        hasher.combine(body)
        hasher.combine(state)
        hasher.combine(stateSource)
        hasher.combine(author)
        hasher.combine(assignees)
        hasher.combine(labels)
        hasher.combine(links)
        hasher.combine(parentRef)
        hasher.combine(createdAt)
        hasher.combine(updatedAt)
        hasher.combine(extras)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeWorkItem: FfiConverterRustBuffer {
    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WorkItem {
        return
            try WorkItem(
                envelope: FfiConverterTypeEnvelope.read(from: &buf), 
                itemRef: FfiConverterTypeItemRef.read(from: &buf), 
                kind: FfiConverterTypeWorkItemKind.read(from: &buf), 
                number: FfiConverterOptionUInt64.read(from: &buf), 
                title: FfiConverterString.read(from: &buf), 
                url: FfiConverterString.read(from: &buf), 
                body: FfiConverterString.read(from: &buf), 
                state: FfiConverterTypeItemState.read(from: &buf), 
                stateSource: FfiConverterString.read(from: &buf), 
                author: FfiConverterOptionTypeIdentity.read(from: &buf), 
                assignees: FfiConverterSequenceTypeIdentity.read(from: &buf), 
                labels: FfiConverterSequenceTypeLabelRef.read(from: &buf), 
                links: FfiConverterSequenceTypeItemLink.read(from: &buf), 
                parentRef: FfiConverterOptionTypeItemRef.read(from: &buf), 
                createdAt: FfiConverterString.read(from: &buf), 
                updatedAt: FfiConverterString.read(from: &buf), 
                extras: FfiConverterDictionaryStringString.read(from: &buf)
        )
    }

    public static func write(_ value: WorkItem, into buf: inout [UInt8]) {
        FfiConverterTypeEnvelope.write(value.envelope, into: &buf)
        FfiConverterTypeItemRef.write(value.itemRef, into: &buf)
        FfiConverterTypeWorkItemKind.write(value.kind, into: &buf)
        FfiConverterOptionUInt64.write(value.number, into: &buf)
        FfiConverterString.write(value.title, into: &buf)
        FfiConverterString.write(value.url, into: &buf)
        FfiConverterString.write(value.body, into: &buf)
        FfiConverterTypeItemState.write(value.state, into: &buf)
        FfiConverterString.write(value.stateSource, into: &buf)
        FfiConverterOptionTypeIdentity.write(value.author, into: &buf)
        FfiConverterSequenceTypeIdentity.write(value.assignees, into: &buf)
        FfiConverterSequenceTypeLabelRef.write(value.labels, into: &buf)
        FfiConverterSequenceTypeItemLink.write(value.links, into: &buf)
        FfiConverterOptionTypeItemRef.write(value.parentRef, into: &buf)
        FfiConverterString.write(value.createdAt, into: &buf)
        FfiConverterString.write(value.updatedAt, into: &buf)
        FfiConverterDictionaryStringString.write(value.extras, into: &buf)
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeWorkItem_lift(_ buf: RustBuffer) throws -> WorkItem {
    return try FfiConverterTypeWorkItem.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeWorkItem_lower(_ value: WorkItem) -> RustBuffer {
    return FfiConverterTypeWorkItem.lower(value)
}

// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * Whether the token's granted access is known, and what it lacks.
 */

public enum AccessCheck {
    
    /**
     * GitHub reported the scopes; `missing` lists what Fjord asks for and the
     * token lacks. Empty means nothing is missing.
     */
    case known(grantedScopes: [String], missing: [RequiredAccess]
    )
    /**
     * GitHub does not expose this token's permissions. A missing permission
     * shows up as a 403 on the action that needs it.
     */
    case unknown
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeAccessCheck: FfiConverterRustBuffer {
    typealias SwiftType = AccessCheck

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AccessCheck {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .known(grantedScopes: try FfiConverterSequenceString.read(from: &buf), missing: try FfiConverterSequenceTypeRequiredAccess.read(from: &buf)
        )
        
        case 2: return .unknown
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: AccessCheck, into buf: inout [UInt8]) {
        switch value {
        
        
        case let .known(grantedScopes,missing):
            writeInt(&buf, Int32(1))
            FfiConverterSequenceString.write(grantedScopes, into: &buf)
            FfiConverterSequenceTypeRequiredAccess.write(missing, into: &buf)
            
        
        case .unknown:
            writeInt(&buf, Int32(2))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeAccessCheck_lift(_ buf: RustBuffer) throws -> AccessCheck {
    return try FfiConverterTypeAccessCheck.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeAccessCheck_lower(_ value: AccessCheck) -> RustBuffer {
    return FfiConverterTypeAccessCheck.lower(value)
}



extension AccessCheck: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * What to do.
 */

public enum ActionKind {
    
    case approve
    case requestChanges
    case comment
    case reply
    case markRead
    case requestReview
    case merge
    case rerun
    case cancel
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeActionKind: FfiConverterRustBuffer {
    typealias SwiftType = ActionKind

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActionKind {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .approve
        
        case 2: return .requestChanges
        
        case 3: return .comment
        
        case 4: return .reply
        
        case 5: return .markRead
        
        case 6: return .requestReview
        
        case 7: return .merge
        
        case 8: return .rerun
        
        case 9: return .cancel
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: ActionKind, into buf: inout [UInt8]) {
        switch value {
        
        
        case .approve:
            writeInt(&buf, Int32(1))
        
        
        case .requestChanges:
            writeInt(&buf, Int32(2))
        
        
        case .comment:
            writeInt(&buf, Int32(3))
        
        
        case .reply:
            writeInt(&buf, Int32(4))
        
        
        case .markRead:
            writeInt(&buf, Int32(5))
        
        
        case .requestReview:
            writeInt(&buf, Int32(6))
        
        
        case .merge:
            writeInt(&buf, Int32(7))
        
        
        case .rerun:
            writeInt(&buf, Int32(8))
        
        
        case .cancel:
            writeInt(&buf, Int32(9))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeActionKind_lift(_ buf: RustBuffer) throws -> ActionKind {
    return try FfiConverterTypeActionKind.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeActionKind_lower(_ value: ActionKind) -> RustBuffer {
    return FfiConverterTypeActionKind.lower(value)
}



extension ActionKind: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * Status of a workflow/action run.
 */

public enum ActionRunStatus {
    
    case pending
    case running
    case success
    case failure
    case cancelled
    case skipped
    case unknown
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeActionRunStatus: FfiConverterRustBuffer {
    typealias SwiftType = ActionRunStatus

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ActionRunStatus {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .pending
        
        case 2: return .running
        
        case 3: return .success
        
        case 4: return .failure
        
        case 5: return .cancelled
        
        case 6: return .skipped
        
        case 7: return .unknown
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: ActionRunStatus, into buf: inout [UInt8]) {
        switch value {
        
        
        case .pending:
            writeInt(&buf, Int32(1))
        
        
        case .running:
            writeInt(&buf, Int32(2))
        
        
        case .success:
            writeInt(&buf, Int32(3))
        
        
        case .failure:
            writeInt(&buf, Int32(4))
        
        
        case .cancelled:
            writeInt(&buf, Int32(5))
        
        
        case .skipped:
            writeInt(&buf, Int32(6))
        
        
        case .unknown:
            writeInt(&buf, Int32(7))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeActionRunStatus_lift(_ buf: RustBuffer) throws -> ActionRunStatus {
    return try FfiConverterTypeActionRunStatus.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeActionRunStatus_lower(_ value: ActionRunStatus) -> RustBuffer {
    return FfiConverterTypeActionRunStatus.lower(value)
}



extension ActionRunStatus: Equatable, Hashable {}




/**
 * A sign-in failure. Each variant maps onto one contract error class
 * ([`AuthError::class`]) and onto the existing [`CoreError`].
 */
public enum AuthError {

    
    
    /**
     * HTTP 401. GitHub answers an expired and a revoked token the same way,
     * so the shell should ask for a new token in both cases.
     */
    case TokenRejected(detail: String
    )
    /**
     * HTTP 403 that is not a rate limit.
     */
    case Forbidden(detail: String
    )
    /**
     * Primary or secondary rate limit, or a 429.
     */
    case RateLimited(retryAfterSecs: UInt64
    )
    /**
     * The flow is not available: no client id is configured, or the provider
     * has the flow turned off for this app.
     */
    case Unsupported(detail: String
    )
    /**
     * The device code expired before the user approved it.
     */
    case DeviceCodeExpired
    /**
     * The user declined the authorization request on the provider's page.
     */
    case AccessDenied
    /**
     * The user cancelled the flow in the app.
     */
    case Cancelled
    /**
     * The provider rejected the request itself (bad client id, bad grant).
     */
    case Rejected(detail: String
    )
    /**
     * The provider returned a 5xx.
     */
    case ProviderDown(status: UInt16
    )
    /**
     * Connect, TLS or timeout failure.
     */
    case Network(reason: String
    )
    /**
     * The response did not have the documented shape.
     */
    case Decode(reason: String
    )
    /**
     * The token store has no token for the account (signed out or removed).
     * The shell should ask the user to sign in again.
     */
    case NoToken(accountId: String
    )
    /**
     * The token store could not be read (device locked, Keystore failure).
     * The token may still be there: retry later, do not sign the user out.
     */
    case TokenStoreUnavailable(reason: String
    )
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeAuthError: FfiConverterRustBuffer {
    typealias SwiftType = AuthError

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> AuthError {
        let variant: Int32 = try readInt(&buf)
        switch variant {

        

        
        case 1: return .TokenRejected(
            detail: try FfiConverterString.read(from: &buf)
            )
        case 2: return .Forbidden(
            detail: try FfiConverterString.read(from: &buf)
            )
        case 3: return .RateLimited(
            retryAfterSecs: try FfiConverterUInt64.read(from: &buf)
            )
        case 4: return .Unsupported(
            detail: try FfiConverterString.read(from: &buf)
            )
        case 5: return .DeviceCodeExpired
        case 6: return .AccessDenied
        case 7: return .Cancelled
        case 8: return .Rejected(
            detail: try FfiConverterString.read(from: &buf)
            )
        case 9: return .ProviderDown(
            status: try FfiConverterUInt16.read(from: &buf)
            )
        case 10: return .Network(
            reason: try FfiConverterString.read(from: &buf)
            )
        case 11: return .Decode(
            reason: try FfiConverterString.read(from: &buf)
            )
        case 12: return .NoToken(
            accountId: try FfiConverterString.read(from: &buf)
            )
        case 13: return .TokenStoreUnavailable(
            reason: try FfiConverterString.read(from: &buf)
            )

         default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: AuthError, into buf: inout [UInt8]) {
        switch value {

        

        
        
        case let .TokenRejected(detail):
            writeInt(&buf, Int32(1))
            FfiConverterString.write(detail, into: &buf)
            
        
        case let .Forbidden(detail):
            writeInt(&buf, Int32(2))
            FfiConverterString.write(detail, into: &buf)
            
        
        case let .RateLimited(retryAfterSecs):
            writeInt(&buf, Int32(3))
            FfiConverterUInt64.write(retryAfterSecs, into: &buf)
            
        
        case let .Unsupported(detail):
            writeInt(&buf, Int32(4))
            FfiConverterString.write(detail, into: &buf)
            
        
        case .DeviceCodeExpired:
            writeInt(&buf, Int32(5))
        
        
        case .AccessDenied:
            writeInt(&buf, Int32(6))
        
        
        case .Cancelled:
            writeInt(&buf, Int32(7))
        
        
        case let .Rejected(detail):
            writeInt(&buf, Int32(8))
            FfiConverterString.write(detail, into: &buf)
            
        
        case let .ProviderDown(status):
            writeInt(&buf, Int32(9))
            FfiConverterUInt16.write(status, into: &buf)
            
        
        case let .Network(reason):
            writeInt(&buf, Int32(10))
            FfiConverterString.write(reason, into: &buf)
            
        
        case let .Decode(reason):
            writeInt(&buf, Int32(11))
            FfiConverterString.write(reason, into: &buf)
            
        
        case let .NoToken(accountId):
            writeInt(&buf, Int32(12))
            FfiConverterString.write(accountId, into: &buf)
            
        
        case let .TokenStoreUnavailable(reason):
            writeInt(&buf, Int32(13))
            FfiConverterString.write(reason, into: &buf)
            
        }
    }
}


extension AuthError: Equatable, Hashable {}

extension AuthError: Foundation.LocalizedError {
    public var errorDescription: String? {
        String(reflecting: self)
    }
}

// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * The evidence label. Only `ProviderRead` and `ProviderEvent` may be shown as
 * verified; `AgentReported` never is.
 */

public enum Basis {
    
    case providerRead
    case providerEvent
    case agentReported
    case fjordRecord
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeBasis: FfiConverterRustBuffer {
    typealias SwiftType = Basis

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Basis {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .providerRead
        
        case 2: return .providerEvent
        
        case 3: return .agentReported
        
        case 4: return .fjordRecord
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: Basis, into buf: inout [UInt8]) {
        switch value {
        
        
        case .providerRead:
            writeInt(&buf, Int32(1))
        
        
        case .providerEvent:
            writeInt(&buf, Int32(2))
        
        
        case .agentReported:
            writeInt(&buf, Int32(3))
        
        
        case .fjordRecord:
            writeInt(&buf, Int32(4))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeBasis_lift(_ buf: RustBuffer) throws -> Basis {
    return try FfiConverterTypeBasis.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeBasis_lower(_ value: Basis) -> RustBuffer {
    return FfiConverterTypeBasis.lower(value)
}



extension Basis: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * Which provider mechanism produced a check.
 */

public enum CheckKind {
    
    case checkRun
    case commitStatus
    case pipeline
    case job
    case actionRun
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCheckKind: FfiConverterRustBuffer {
    typealias SwiftType = CheckKind

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CheckKind {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .checkRun
        
        case 2: return .commitStatus
        
        case 3: return .pipeline
        
        case 4: return .job
        
        case 5: return .actionRun
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: CheckKind, into buf: inout [UInt8]) {
        switch value {
        
        
        case .checkRun:
            writeInt(&buf, Int32(1))
        
        
        case .commitStatus:
            writeInt(&buf, Int32(2))
        
        
        case .pipeline:
            writeInt(&buf, Int32(3))
        
        
        case .job:
            writeInt(&buf, Int32(4))
        
        
        case .actionRun:
            writeInt(&buf, Int32(5))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCheckKind_lift(_ buf: RustBuffer) throws -> CheckKind {
    return try FfiConverterTypeCheckKind.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCheckKind_lower(_ value: CheckKind) -> RustBuffer {
    return FfiConverterTypeCheckKind.lower(value)
}



extension CheckKind: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * Normalized state of one check, or of the rollup.
 */

public enum CheckState {
    
    case pending
    case running
    case success
    case failure
    case cancelled
    case skipped
    /**
     * The provider reported no checks at all. Contract value `none`.
     */
    case noChecks
    /**
     * The adapter could not find out (not found in the window it read).
     */
    case unknown
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCheckState: FfiConverterRustBuffer {
    typealias SwiftType = CheckState

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CheckState {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .pending
        
        case 2: return .running
        
        case 3: return .success
        
        case 4: return .failure
        
        case 5: return .cancelled
        
        case 6: return .skipped
        
        case 7: return .noChecks
        
        case 8: return .unknown
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: CheckState, into buf: inout [UInt8]) {
        switch value {
        
        
        case .pending:
            writeInt(&buf, Int32(1))
        
        
        case .running:
            writeInt(&buf, Int32(2))
        
        
        case .success:
            writeInt(&buf, Int32(3))
        
        
        case .failure:
            writeInt(&buf, Int32(4))
        
        
        case .cancelled:
            writeInt(&buf, Int32(5))
        
        
        case .skipped:
            writeInt(&buf, Int32(6))
        
        
        case .noChecks:
            writeInt(&buf, Int32(7))
        
        
        case .unknown:
            writeInt(&buf, Int32(8))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCheckState_lift(_ buf: RustBuffer) throws -> CheckState {
    return try FfiConverterTypeCheckState.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCheckState_lower(_ value: CheckState) -> RustBuffer {
    return FfiConverterTypeCheckState.lower(value)
}



extension CheckState: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * Where a comment sits.
 */

public enum CommentKind {
    
    /**
     * The conversation on an issue or change request.
     */
    case issue
    /**
     * The body of a submitted review.
     */
    case review
    /**
     * Attached to a line of the diff.
     */
    case inline
    /**
     * A system or note entry.
     */
    case note
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCommentKind: FfiConverterRustBuffer {
    typealias SwiftType = CommentKind

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CommentKind {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .issue
        
        case 2: return .review
        
        case 3: return .inline
        
        case 4: return .note
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: CommentKind, into buf: inout [UInt8]) {
        switch value {
        
        
        case .issue:
            writeInt(&buf, Int32(1))
        
        
        case .review:
            writeInt(&buf, Int32(2))
        
        
        case .inline:
            writeInt(&buf, Int32(3))
        
        
        case .note:
            writeInt(&buf, Int32(4))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCommentKind_lift(_ buf: RustBuffer) throws -> CommentKind {
    return try FfiConverterTypeCommentKind.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeCommentKind_lower(_ value: CommentKind) -> RustBuffer {
    return FfiConverterTypeCommentKind.lower(value)
}



extension CommentKind: Equatable, Hashable {}




/**
 * A failure from a fjord-core operation.
 */
public enum CoreError {

    
    
    /**
     * No valid session; the shell must (re-)authenticate.
     */
    case NotAuthenticated(message: String)
    
    /**
     * Authenticated, but not allowed to perform the action.
     */
    case Forbidden(message: String)
    
    /**
     * The requested resource does not exist.
     */
    case NotFound(message: String)
    
    /**
     * Rate limited by the server; retry after the given seconds.
     */
    case RateLimited(message: String)
    
    /**
     * The server returned a 5xx.
     */
    case Server(message: String)
    
    /**
     * A transport-level failure (connection, TLS, timeout).
     */
    case Network(message: String)
    
    /**
     * The request was rejected as invalid (4xx other than auth/not-found).
     */
    case Validation(message: String)
    
    /**
     * The action conflicts with current server state.
     */
    case Conflict(message: String)
    
    /**
     * Offline and the data is not cached.
     */
    case Offline(message: String)
    
    /**
     * The response could not be decoded into a known shape.
     */
    case Decode(message: String)
    
    /**
     * The local cache (SQLite) could not be opened, read, or written.
     */
    case Cache(message: String)
    
    /**
     * The platform credential store (Keychain, Keystore) could not be read or
     * written, for example while the device is locked. Retryable, and never
     * a reason to sign the user out: the token may still be there.
     */
    case CredentialStoreUnavailable(message: String)
    
    /**
     * The provider, instance, or account does not offer this operation.
     * Not retryable; the shell should hide or disable the affordance.
     */
    case Unsupported(message: String)
    
    /**
     * The user cancelled the operation. Not an error to show, and not
     * retryable on its own.
     */
    case Cancelled(message: String)
    
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeCoreError: FfiConverterRustBuffer {
    typealias SwiftType = CoreError

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> CoreError {
        let variant: Int32 = try readInt(&buf)
        switch variant {

        

        
        case 1: return .NotAuthenticated(
            message: try FfiConverterString.read(from: &buf)
        )
        
        case 2: return .Forbidden(
            message: try FfiConverterString.read(from: &buf)
        )
        
        case 3: return .NotFound(
            message: try FfiConverterString.read(from: &buf)
        )
        
        case 4: return .RateLimited(
            message: try FfiConverterString.read(from: &buf)
        )
        
        case 5: return .Server(
            message: try FfiConverterString.read(from: &buf)
        )
        
        case 6: return .Network(
            message: try FfiConverterString.read(from: &buf)
        )
        
        case 7: return .Validation(
            message: try FfiConverterString.read(from: &buf)
        )
        
        case 8: return .Conflict(
            message: try FfiConverterString.read(from: &buf)
        )
        
        case 9: return .Offline(
            message: try FfiConverterString.read(from: &buf)
        )
        
        case 10: return .Decode(
            message: try FfiConverterString.read(from: &buf)
        )
        
        case 11: return .Cache(
            message: try FfiConverterString.read(from: &buf)
        )
        
        case 12: return .CredentialStoreUnavailable(
            message: try FfiConverterString.read(from: &buf)
        )
        
        case 13: return .Unsupported(
            message: try FfiConverterString.read(from: &buf)
        )
        
        case 14: return .Cancelled(
            message: try FfiConverterString.read(from: &buf)
        )
        

        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: CoreError, into buf: inout [UInt8]) {
        switch value {

        

        
        case .NotAuthenticated(_ /* message is ignored*/):
            writeInt(&buf, Int32(1))
        case .Forbidden(_ /* message is ignored*/):
            writeInt(&buf, Int32(2))
        case .NotFound(_ /* message is ignored*/):
            writeInt(&buf, Int32(3))
        case .RateLimited(_ /* message is ignored*/):
            writeInt(&buf, Int32(4))
        case .Server(_ /* message is ignored*/):
            writeInt(&buf, Int32(5))
        case .Network(_ /* message is ignored*/):
            writeInt(&buf, Int32(6))
        case .Validation(_ /* message is ignored*/):
            writeInt(&buf, Int32(7))
        case .Conflict(_ /* message is ignored*/):
            writeInt(&buf, Int32(8))
        case .Offline(_ /* message is ignored*/):
            writeInt(&buf, Int32(9))
        case .Decode(_ /* message is ignored*/):
            writeInt(&buf, Int32(10))
        case .Cache(_ /* message is ignored*/):
            writeInt(&buf, Int32(11))
        case .CredentialStoreUnavailable(_ /* message is ignored*/):
            writeInt(&buf, Int32(12))
        case .Unsupported(_ /* message is ignored*/):
            writeInt(&buf, Int32(13))
        case .Cancelled(_ /* message is ignored*/):
            writeInt(&buf, Int32(14))

        
        }
    }
}


extension CoreError: Equatable, Hashable {}

extension CoreError: Foundation.LocalizedError {
    public var errorDescription: String? {
        String(reflecting: self)
    }
}

// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * The contract error class.
 */

public enum ErrorClass {
    
    case auth
    case permission
    case notFound
    case conflict
    case rateLimited
    case unsupported
    case providerDown
    case stalePrecondition
    /**
     * The request was wrong: a bad argument, locator or page token, or a
     * 4xx the other classes do not cover. Fix the request; do not retry.
     */
    case invalid
    /**
     * The provider answered 2xx, but the body is not the documented shape:
     * a schema change, a proxy's error page, or a truncated body. Not the
     * caller's fault and not retried automatically; the shell keeps the
     * last good object marked stale and offers a manual refresh.
     */
    case decode
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeErrorClass: FfiConverterRustBuffer {
    typealias SwiftType = ErrorClass

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ErrorClass {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .auth
        
        case 2: return .permission
        
        case 3: return .notFound
        
        case 4: return .conflict
        
        case 5: return .rateLimited
        
        case 6: return .unsupported
        
        case 7: return .providerDown
        
        case 8: return .stalePrecondition
        
        case 9: return .invalid
        
        case 10: return .decode
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: ErrorClass, into buf: inout [UInt8]) {
        switch value {
        
        
        case .auth:
            writeInt(&buf, Int32(1))
        
        
        case .permission:
            writeInt(&buf, Int32(2))
        
        
        case .notFound:
            writeInt(&buf, Int32(3))
        
        
        case .conflict:
            writeInt(&buf, Int32(4))
        
        
        case .rateLimited:
            writeInt(&buf, Int32(5))
        
        
        case .unsupported:
            writeInt(&buf, Int32(6))
        
        
        case .providerDown:
            writeInt(&buf, Int32(7))
        
        
        case .stalePrecondition:
            writeInt(&buf, Int32(8))
        
        
        case .invalid:
            writeInt(&buf, Int32(9))
        
        
        case .decode:
            writeInt(&buf, Int32(10))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeErrorClass_lift(_ buf: RustBuffer) throws -> ErrorClass {
    return try FfiConverterTypeErrorClass.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeErrorClass_lower(_ value: ErrorClass) -> RustBuffer {
    return FfiConverterTypeErrorClass.lower(value)
}



extension ErrorClass: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * Where a flag's answer comes from, using the CLS-883 tags.
 */

public enum FlagSource {
    
    /**
     * Tested against a live instance.
     */
    case tested
    /**
     * Read from the provider's swagger or schema.
     */
    case schema
    /**
     * Read from vendor documentation.
     */
    case docs
    /**
     * Observed in this fleet.
     */
    case observed
    /**
     * Probed at runtime for this account.
     */
    case probed
    /**
     * Not established.
     */
    case unsourced
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeFlagSource: FfiConverterRustBuffer {
    typealias SwiftType = FlagSource

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> FlagSource {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .tested
        
        case 2: return .schema
        
        case 3: return .docs
        
        case 4: return .observed
        
        case 5: return .probed
        
        case 6: return .unsourced
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: FlagSource, into buf: inout [UInt8]) {
        switch value {
        
        
        case .tested:
            writeInt(&buf, Int32(1))
        
        
        case .schema:
            writeInt(&buf, Int32(2))
        
        
        case .docs:
            writeInt(&buf, Int32(3))
        
        
        case .observed:
            writeInt(&buf, Int32(4))
        
        
        case .probed:
            writeInt(&buf, Int32(5))
        
        
        case .unsourced:
            writeInt(&buf, Int32(6))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFlagSource_lift(_ buf: RustBuffer) throws -> FlagSource {
    return try FfiConverterTypeFlagSource.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFlagSource_lower(_ value: FlagSource) -> RustBuffer {
    return FfiConverterTypeFlagSource.lower(value)
}



extension FlagSource: Equatable, Hashable {}




/**
 * A failed provider call, as the shells see it. `Provider` carries the
 * contract class the UI branches on; the status and detail are for
 * diagnostics and are never parsed. Details are already free of tokens.
 *
 * The field is `detail`, never `message`: a Kotlin exception field named
 * `message` clashes with `Throwable.message` and the bindings stop compiling.
 */
public enum ForgeCallError {

    
    
    /**
     * The provider, or the path to it, failed in a way the contract names.
     */
    case Provider(`class`: ErrorClass, 
        /**
         * HTTP status, when a response arrived.
         */status: UInt16?, 
        /**
         * What went wrong, for logs.
         */detail: String, 
        /**
         * Seconds to wait, for `RateLimited` when the provider says.
         */retryAfterSecs: UInt64?
    )
    /**
     * The shell set the call's cancel flag.
     */
    case Cancelled
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeForgeCallError: FfiConverterRustBuffer {
    typealias SwiftType = ForgeCallError

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ForgeCallError {
        let variant: Int32 = try readInt(&buf)
        switch variant {

        

        
        case 1: return .Provider(
            `class`: try FfiConverterTypeErrorClass.read(from: &buf), 
            status: try FfiConverterOptionUInt16.read(from: &buf), 
            detail: try FfiConverterString.read(from: &buf), 
            retryAfterSecs: try FfiConverterOptionUInt64.read(from: &buf)
            )
        case 2: return .Cancelled

         default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: ForgeCallError, into buf: inout [UInt8]) {
        switch value {

        

        
        
        case let .Provider(`class`,status,detail,retryAfterSecs):
            writeInt(&buf, Int32(1))
            FfiConverterTypeErrorClass.write(`class`, into: &buf)
            FfiConverterOptionUInt16.write(status, into: &buf)
            FfiConverterString.write(detail, into: &buf)
            FfiConverterOptionUInt64.write(retryAfterSecs, into: &buf)
            
        
        case .Cancelled:
            writeInt(&buf, Int32(2))
        
        }
    }
}


extension ForgeCallError: Equatable, Hashable {}

extension ForgeCallError: Foundation.LocalizedError {
    public var errorDescription: String? {
        String(reflecting: self)
    }
}

// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * How current a cached entry is relative to its TTL. There is no "expired,
 * discard" state: stale data is still worth serving offline or instantly while
 * a refresh runs. Physical removal is [eviction](CachePolicy::should_evict),
 * driven by age and capacity, not freshness.
 */

public enum Freshness {
    
    /**
     * Within the TTL: serve without refetching.
     */
    case fresh
    /**
     * Past the TTL: serve from cache (offline-first), but revalidate.
     */
    case stale
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeFreshness: FfiConverterRustBuffer {
    typealias SwiftType = Freshness

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Freshness {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .fresh
        
        case 2: return .stale
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: Freshness, into buf: inout [UInt8]) {
        switch value {
        
        
        case .fresh:
            writeInt(&buf, Int32(1))
        
        
        case .stale:
            writeInt(&buf, Int32(2))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFreshness_lift(_ buf: RustBuffer) throws -> Freshness {
    return try FfiConverterTypeFreshness.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeFreshness_lower(_ value: Freshness) -> RustBuffer {
    return FfiConverterTypeFreshness.lower(value)
}



extension Freshness: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * What kind of principal an identity is, as the provider says. Never inferred
 * from the login.
 */

public enum IdentityKind {
    
    case human
    case bot
    case app
    case unknown
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeIdentityKind: FfiConverterRustBuffer {
    typealias SwiftType = IdentityKind

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> IdentityKind {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .human
        
        case 2: return .bot
        
        case 3: return .app
        
        case 4: return .unknown
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: IdentityKind, into buf: inout [UInt8]) {
        switch value {
        
        
        case .human:
            writeInt(&buf, Int32(1))
        
        
        case .bot:
            writeInt(&buf, Int32(2))
        
        
        case .app:
            writeInt(&buf, Int32(3))
        
        
        case .unknown:
            writeInt(&buf, Int32(4))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeIdentityKind_lift(_ buf: RustBuffer) throws -> IdentityKind {
    return try FfiConverterTypeIdentityKind.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeIdentityKind_lower(_ value: IdentityKind) -> RustBuffer {
    return FfiConverterTypeIdentityKind.lower(value)
}



extension IdentityKind: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * What an [`ItemRef`] points at.
 */

public enum ItemKind {
    
    case repository
    case issue
    case changeRequest
    case review
    case comment
    case commit
    case other
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeItemKind: FfiConverterRustBuffer {
    typealias SwiftType = ItemKind

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ItemKind {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .repository
        
        case 2: return .issue
        
        case 3: return .changeRequest
        
        case 4: return .review
        
        case 5: return .comment
        
        case 6: return .commit
        
        case 7: return .other
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: ItemKind, into buf: inout [UInt8]) {
        switch value {
        
        
        case .repository:
            writeInt(&buf, Int32(1))
        
        
        case .issue:
            writeInt(&buf, Int32(2))
        
        
        case .changeRequest:
            writeInt(&buf, Int32(3))
        
        
        case .review:
            writeInt(&buf, Int32(4))
        
        
        case .comment:
            writeInt(&buf, Int32(5))
        
        
        case .commit:
            writeInt(&buf, Int32(6))
        
        
        case .other:
            writeInt(&buf, Int32(7))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeItemKind_lift(_ buf: RustBuffer) throws -> ItemKind {
    return try FfiConverterTypeItemKind.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeItemKind_lower(_ value: ItemKind) -> RustBuffer {
    return FfiConverterTypeItemKind.lower(value)
}



extension ItemKind: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * Normalized work item state.
 */

public enum ItemState {
    
    case `open`
    case closed
    case merged
    case draft
    case other
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeItemState: FfiConverterRustBuffer {
    typealias SwiftType = ItemState

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ItemState {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .`open`
        
        case 2: return .closed
        
        case 3: return .merged
        
        case 4: return .draft
        
        case 5: return .other
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: ItemState, into buf: inout [UInt8]) {
        switch value {
        
        
        case .`open`:
            writeInt(&buf, Int32(1))
        
        
        case .closed:
            writeInt(&buf, Int32(2))
        
        
        case .merged:
            writeInt(&buf, Int32(3))
        
        
        case .draft:
            writeInt(&buf, Int32(4))
        
        
        case .other:
            writeInt(&buf, Int32(5))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeItemState_lift(_ buf: RustBuffer) throws -> ItemState {
    return try FfiConverterTypeItemState.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeItemState_lower(_ value: ItemState) -> RustBuffer {
    return FfiConverterTypeItemState.lower(value)
}



extension ItemState: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * How a ship merges each PR. Mirrors fj's Forgejo merge styles; `as_str`
 * yields the exact API token Forgejo expects.
 */

public enum MergeStyle {
    
    case merge
    case rebase
    case rebaseMerge
    case squash
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeMergeStyle: FfiConverterRustBuffer {
    typealias SwiftType = MergeStyle

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> MergeStyle {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .merge
        
        case 2: return .rebase
        
        case 3: return .rebaseMerge
        
        case 4: return .squash
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: MergeStyle, into buf: inout [UInt8]) {
        switch value {
        
        
        case .merge:
            writeInt(&buf, Int32(1))
        
        
        case .rebase:
            writeInt(&buf, Int32(2))
        
        
        case .rebaseMerge:
            writeInt(&buf, Int32(3))
        
        
        case .squash:
            writeInt(&buf, Int32(4))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeMergeStyle_lift(_ buf: RustBuffer) throws -> MergeStyle {
    return try FfiConverterTypeMergeStyle.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeMergeStyle_lower(_ value: MergeStyle) -> RustBuffer {
    return FfiConverterTypeMergeStyle.lower(value)
}



extension MergeStyle: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * The provider kind. `Unknown` keeps the name a server or the shell reported,
 * so a new provider degrades to "unknown" instead of failing to decode.
 */

public enum ProviderKind {
    
    case forgejo
    case gitea
    case github
    case unknown(name: String
    )
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeProviderKind: FfiConverterRustBuffer {
    typealias SwiftType = ProviderKind

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ProviderKind {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .forgejo
        
        case 2: return .gitea
        
        case 3: return .github
        
        case 4: return .unknown(name: try FfiConverterString.read(from: &buf)
        )
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: ProviderKind, into buf: inout [UInt8]) {
        switch value {
        
        
        case .forgejo:
            writeInt(&buf, Int32(1))
        
        
        case .gitea:
            writeInt(&buf, Int32(2))
        
        
        case .github:
            writeInt(&buf, Int32(3))
        
        
        case let .unknown(name):
            writeInt(&buf, Int32(4))
            FfiConverterString.write(name, into: &buf)
            
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeProviderKind_lift(_ buf: RustBuffer) throws -> ProviderKind {
    return try FfiConverterTypeProviderKind.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeProviderKind_lower(_ value: ProviderKind) -> RustBuffer {
    return FfiConverterTypeProviderKind.lower(value)
}



extension ProviderKind: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * Where a pull request sits in its lifecycle.
 */

public enum PullRequestState {
    
    case `open`
    case merged
    case closed
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypePullRequestState: FfiConverterRustBuffer {
    typealias SwiftType = PullRequestState

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> PullRequestState {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .`open`
        
        case 2: return .merged
        
        case 3: return .closed
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: PullRequestState, into buf: inout [UInt8]) {
        switch value {
        
        
        case .`open`:
            writeInt(&buf, Int32(1))
        
        
        case .merged:
            writeInt(&buf, Int32(2))
        
        
        case .closed:
            writeInt(&buf, Int32(3))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePullRequestState_lift(_ buf: RustBuffer) throws -> PullRequestState {
    return try FfiConverterTypePullRequestState.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypePullRequestState_lower(_ value: PullRequestState) -> RustBuffer {
    return FfiConverterTypePullRequestState.lower(value)
}



extension PullRequestState: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * Normalized merge readiness. `Unknown` is legal and is the answer whenever
 * the adapter cannot tell (for example Forgejo `mergeable=false` right after
 * a push, or GitHub `mergeable=null` while it computes).
 */

public enum Readiness {
    
    case ready
    case blocked
    case conflict
    case checking
    case unknown
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeReadiness: FfiConverterRustBuffer {
    typealias SwiftType = Readiness

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Readiness {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .ready
        
        case 2: return .blocked
        
        case 3: return .conflict
        
        case 4: return .checking
        
        case 5: return .unknown
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: Readiness, into buf: inout [UInt8]) {
        switch value {
        
        
        case .ready:
            writeInt(&buf, Int32(1))
        
        
        case .blocked:
            writeInt(&buf, Int32(2))
        
        
        case .conflict:
            writeInt(&buf, Int32(3))
        
        
        case .checking:
            writeInt(&buf, Int32(4))
        
        
        case .unknown:
            writeInt(&buf, Int32(5))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeReadiness_lift(_ buf: RustBuffer) throws -> Readiness {
    return try FfiConverterTypeReadiness.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeReadiness_lower(_ value: Readiness) -> RustBuffer {
    return FfiConverterTypeReadiness.lower(value)
}



extension Readiness: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * Access Fjord asks for, named for the shell rather than by GitHub scope.
 */

public enum RequiredAccess {
    
    /**
     * Read and write private and public repositories (`repo`).
     */
    case repositories
    /**
     * Read the notifications inbox (`notifications`, or `repo`).
     */
    case notifications
    /**
     * Read organization and team membership (`read:org`).
     */
    case organizations
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeRequiredAccess: FfiConverterRustBuffer {
    typealias SwiftType = RequiredAccess

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> RequiredAccess {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .repositories
        
        case 2: return .notifications
        
        case 3: return .organizations
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: RequiredAccess, into buf: inout [UInt8]) {
        switch value {
        
        
        case .repositories:
            writeInt(&buf, Int32(1))
        
        
        case .notifications:
            writeInt(&buf, Int32(2))
        
        
        case .organizations:
            writeInt(&buf, Int32(3))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRequiredAccess_lift(_ buf: RustBuffer) throws -> RequiredAccess {
    return try FfiConverterTypeRequiredAccess.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeRequiredAccess_lower(_ value: RequiredAccess) -> RustBuffer {
    return FfiConverterTypeRequiredAccess.lower(value)
}



extension RequiredAccess: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * Normalized review state.
 */

public enum ReviewState {
    
    case approved
    case changesRequested
    case commented
    case dismissed
    case pending
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeReviewState: FfiConverterRustBuffer {
    typealias SwiftType = ReviewState

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ReviewState {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .approved
        
        case 2: return .changesRequested
        
        case 3: return .commented
        
        case 4: return .dismissed
        
        case 5: return .pending
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: ReviewState, into buf: inout [UInt8]) {
        switch value {
        
        
        case .approved:
            writeInt(&buf, Int32(1))
        
        
        case .changesRequested:
            writeInt(&buf, Int32(2))
        
        
        case .commented:
            writeInt(&buf, Int32(3))
        
        
        case .dismissed:
            writeInt(&buf, Int32(4))
        
        
        case .pending:
            writeInt(&buf, Int32(5))
        
        }
    }
}


#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)
}



extension ReviewState: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * The aggregate review verdict for a PR. Request-changes dominates an approval;
 * an approval dominates plain comments; no reviews → `None`.
 */

public enum ReviewSummary {
    
    case changesRequested
    case approved
    case commented
    case none
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeReviewSummary: FfiConverterRustBuffer {
    typealias SwiftType = ReviewSummary

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ReviewSummary {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .changesRequested
        
        case 2: return .approved
        
        case 3: return .commented
        
        case 4: return .none
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: ReviewSummary, into buf: inout [UInt8]) {
        switch value {
        
        
        case .changesRequested:
            writeInt(&buf, Int32(1))
        
        
        case .approved:
            writeInt(&buf, Int32(2))
        
        
        case .commented:
            writeInt(&buf, Int32(3))
        
        
        case .none:
            writeInt(&buf, Int32(4))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeReviewSummary_lift(_ buf: RustBuffer) throws -> ReviewSummary {
    return try FfiConverterTypeReviewSummary.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeReviewSummary_lower(_ value: ReviewSummary) -> RustBuffer {
    return FfiConverterTypeReviewSummary.lower(value)
}



extension ReviewSummary: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * Who was asked to review.
 */

public enum Reviewer {
    
    case user(identity: Identity
    )
    case team(team: TeamRef
    )
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeReviewer: FfiConverterRustBuffer {
    typealias SwiftType = Reviewer

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Reviewer {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .user(identity: try FfiConverterTypeIdentity.read(from: &buf)
        )
        
        case 2: return .team(team: try FfiConverterTypeTeamRef.read(from: &buf)
        )
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: Reviewer, into buf: inout [UInt8]) {
        switch value {
        
        
        case let .user(identity):
            writeInt(&buf, Int32(1))
            FfiConverterTypeIdentity.write(identity, into: &buf)
            
        
        case let .team(team):
            writeInt(&buf, Int32(2))
            FfiConverterTypeTeamRef.write(team, into: &buf)
            
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeReviewer_lift(_ buf: RustBuffer) throws -> Reviewer {
    return try FfiConverterTypeReviewer.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeReviewer_lower(_ value: Reviewer) -> RustBuffer {
    return FfiConverterTypeReviewer.lower(value)
}



extension Reviewer: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * Whether the issued token has been checked with `GET /user` yet.
 */

public enum SignInValidation {
    
    /**
     * The token works; this is the account's identity.
     */
    case validated(validation: TokenValidation
    )
    /**
     * `GET /user` failed with a retryable error. Save the token and call
     * `validate_token` again later, after `retry_after_secs` when given.
     */
    case deferred(reason: String, retryAfterSecs: UInt64?
    )
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeSignInValidation: FfiConverterRustBuffer {
    typealias SwiftType = SignInValidation

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SignInValidation {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .validated(validation: try FfiConverterTypeTokenValidation.read(from: &buf)
        )
        
        case 2: return .deferred(reason: try FfiConverterString.read(from: &buf), retryAfterSecs: try FfiConverterOptionUInt64.read(from: &buf)
        )
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: SignInValidation, into buf: inout [UInt8]) {
        switch value {
        
        
        case let .validated(validation):
            writeInt(&buf, Int32(1))
            FfiConverterTypeTokenValidation.write(validation, into: &buf)
            
        
        case let .deferred(reason,retryAfterSecs):
            writeInt(&buf, Int32(2))
            FfiConverterString.write(reason, into: &buf)
            FfiConverterOptionUInt64.write(retryAfterSecs, into: &buf)
            
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeSignInValidation_lift(_ buf: RustBuffer) throws -> SignInValidation {
    return try FfiConverterTypeSignInValidation.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeSignInValidation_lower(_ value: SignInValidation) -> RustBuffer {
    return FfiConverterTypeSignInValidation.lower(value)
}



extension SignInValidation: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * How [`Review::stale`] was decided.
 */

public enum StaleMethod {
    
    /**
     * The provider's own stale flag (lags a push on Forgejo).
     */
    case providerFlag
    /**
     * `commit_id` compared with the change request head.
     */
    case commitCompare
    /**
     * Not decided; `stale` is `None`.
     */
    case unavailable
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeStaleMethod: FfiConverterRustBuffer {
    typealias SwiftType = StaleMethod

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> StaleMethod {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .providerFlag
        
        case 2: return .commitCompare
        
        case 3: return .unavailable
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: StaleMethod, into buf: inout [UInt8]) {
        switch value {
        
        
        case .providerFlag:
            writeInt(&buf, Int32(1))
        
        
        case .commitCompare:
            writeInt(&buf, Int32(2))
        
        
        case .unavailable:
            writeInt(&buf, Int32(3))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeStaleMethod_lift(_ buf: RustBuffer) throws -> StaleMethod {
    return try FfiConverterTypeStaleMethod.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeStaleMethod_lower(_ value: StaleMethod) -> RustBuffer {
    return FfiConverterTypeStaleMethod.lower(value)
}



extension StaleMethod: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * How [`ThreadState::unresolved_count`] was obtained.
 */

public enum ThreadMethod {
    
    /**
     * A provider field (GitHub `PullRequestReviewThread.isResolved`).
     */
    case graphqlField
    /**
     * Counted from per-comment resolver data (Forgejo, Gitea).
     */
    case countedFromComments
    case unavailable
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeThreadMethod: FfiConverterRustBuffer {
    typealias SwiftType = ThreadMethod

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ThreadMethod {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .graphqlField
        
        case 2: return .countedFromComments
        
        case 3: return .unavailable
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: ThreadMethod, into buf: inout [UInt8]) {
        switch value {
        
        
        case .graphqlField:
            writeInt(&buf, Int32(1))
        
        
        case .countedFromComments:
            writeInt(&buf, Int32(2))
        
        
        case .unavailable:
            writeInt(&buf, Int32(3))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeThreadMethod_lift(_ buf: RustBuffer) throws -> ThreadMethod {
    return try FfiConverterTypeThreadMethod.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeThreadMethod_lower(_ value: ThreadMethod) -> RustBuffer {
    return FfiConverterTypeThreadMethod.lower(value)
}



extension ThreadMethod: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * The token family, read from GitHub's documented token prefixes.
 */

public enum TokenKind {
    
    case fineGrainedPat
    case classicPat
    case oAuth
    case gitHubAppUser
    case unknown
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeTokenKind: FfiConverterRustBuffer {
    typealias SwiftType = TokenKind

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TokenKind {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .fineGrainedPat
        
        case 2: return .classicPat
        
        case 3: return .oAuth
        
        case 4: return .gitHubAppUser
        
        case 5: return .unknown
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: TokenKind, into buf: inout [UInt8]) {
        switch value {
        
        
        case .fineGrainedPat:
            writeInt(&buf, Int32(1))
        
        
        case .classicPat:
            writeInt(&buf, Int32(2))
        
        
        case .oAuth:
            writeInt(&buf, Int32(3))
        
        
        case .gitHubAppUser:
            writeInt(&buf, Int32(4))
        
        
        case .unknown:
            writeInt(&buf, Int32(5))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeTokenKind_lift(_ buf: RustBuffer) throws -> TokenKind {
    return try FfiConverterTypeTokenKind.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeTokenKind_lower(_ value: TokenKind) -> RustBuffer {
    return FfiConverterTypeTokenKind.lower(value)
}



extension TokenKind: Equatable, Hashable {}




/**
 * A failure inside the shell's store.
 */
public enum TokenStoreError {

    
    
    /**
     * The store could not be read (locked device, Keystore failure).
     */
    case Unavailable(reason: String
    )
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeTokenStoreError: FfiConverterRustBuffer {
    typealias SwiftType = TokenStoreError

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> TokenStoreError {
        let variant: Int32 = try readInt(&buf)
        switch variant {

        

        
        case 1: return .Unavailable(
            reason: try FfiConverterString.read(from: &buf)
            )

         default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: TokenStoreError, into buf: inout [UInt8]) {
        switch value {

        

        
        
        case let .Unavailable(reason):
            writeInt(&buf, Int32(1))
            FfiConverterString.write(reason, into: &buf)
            
        }
    }
}


extension TokenStoreError: Equatable, Hashable {}

extension TokenStoreError: Foundation.LocalizedError {
    public var errorDescription: String? {
        String(reflecting: self)
    }
}

// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * A tri-state capability answer.
 */

public enum Tri {
    
    case yes
    case no
    case unknown
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeTri: FfiConverterRustBuffer {
    typealias SwiftType = Tri

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> Tri {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .yes
        
        case 2: return .no
        
        case 3: return .unknown
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: Tri, into buf: inout [UInt8]) {
        switch value {
        
        
        case .yes:
            writeInt(&buf, Int32(1))
        
        
        case .no:
            writeInt(&buf, Int32(2))
        
        
        case .unknown:
            writeInt(&buf, Int32(3))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeTri_lift(_ buf: RustBuffer) throws -> Tri {
    return try FfiConverterTypeTri.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeTri_lower(_ value: Tri) -> RustBuffer {
    return FfiConverterTypeTri.lower(value)
}



extension Tri: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * What a work item is. `change_request` covers GitHub/Forgejo/Gitea PRs and
 * GitLab MRs; the UI chooses the word.
 */

public enum WorkItemKind {
    
    case issue
    case changeRequest
    case milestone
    case container
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeWorkItemKind: FfiConverterRustBuffer {
    typealias SwiftType = WorkItemKind

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WorkItemKind {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .issue
        
        case 2: return .changeRequest
        
        case 3: return .milestone
        
        case 4: return .container
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: WorkItemKind, into buf: inout [UInt8]) {
        switch value {
        
        
        case .issue:
            writeInt(&buf, Int32(1))
        
        
        case .changeRequest:
            writeInt(&buf, Int32(2))
        
        
        case .milestone:
            writeInt(&buf, Int32(3))
        
        
        case .container:
            writeInt(&buf, Int32(4))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeWorkItemKind_lift(_ buf: RustBuffer) throws -> WorkItemKind {
    return try FfiConverterTypeWorkItemKind.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeWorkItemKind_lower(_ value: WorkItemKind) -> RustBuffer {
    return FfiConverterTypeWorkItemKind.lower(value)
}



extension WorkItemKind: Equatable, Hashable {}



// Note that we don't yet support `indirect` for enums.
// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
/**
 * Open/closed state shared by issues and pull requests.
 */

public enum WorkItemState {
    
    case `open`
    case closed
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public struct FfiConverterTypeWorkItemState: FfiConverterRustBuffer {
    typealias SwiftType = WorkItemState

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> WorkItemState {
        let variant: Int32 = try readInt(&buf)
        switch variant {
        
        case 1: return .`open`
        
        case 2: return .closed
        
        default: throw UniffiInternalError.unexpectedEnumCase
        }
    }

    public static func write(_ value: WorkItemState, into buf: inout [UInt8]) {
        switch value {
        
        
        case .`open`:
            writeInt(&buf, Int32(1))
        
        
        case .closed:
            writeInt(&buf, Int32(2))
        
        }
    }
}


#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeWorkItemState_lift(_ buf: RustBuffer) throws -> WorkItemState {
    return try FfiConverterTypeWorkItemState.lift(buf)
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
public func FfiConverterTypeWorkItemState_lower(_ value: WorkItemState) -> RustBuffer {
    return FfiConverterTypeWorkItemState.lower(value)
}



extension WorkItemState: Equatable, Hashable {}



#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionUInt16: FfiConverterRustBuffer {
    typealias SwiftType = UInt16?

    public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
        guard let value = value else {
            writeInt(&buf, Int8(0))
            return
        }
        writeInt(&buf, Int8(1))
        FfiConverterUInt16.write(value, into: &buf)
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
        switch try readInt(&buf) as Int8 {
        case 0: return nil
        case 1: return try FfiConverterUInt16.read(from: &buf)
        default: throw UniffiInternalError.unexpectedOptionalTag
        }
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionUInt32: FfiConverterRustBuffer {
    typealias SwiftType = UInt32?

    public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
        guard let value = value else {
            writeInt(&buf, Int8(0))
            return
        }
        writeInt(&buf, Int8(1))
        FfiConverterUInt32.write(value, into: &buf)
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
        switch try readInt(&buf) as Int8 {
        case 0: return nil
        case 1: return try FfiConverterUInt32.read(from: &buf)
        default: throw UniffiInternalError.unexpectedOptionalTag
        }
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct 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 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 FfiConverterOptionTypeActionError: FfiConverterRustBuffer {
    typealias SwiftType = ActionError?

    public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
        guard let value = value else {
            writeInt(&buf, Int8(0))
            return
        }
        writeInt(&buf, Int8(1))
        FfiConverterTypeActionError.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 FfiConverterTypeActionError.read(from: &buf)
        default: throw UniffiInternalError.unexpectedOptionalTag
        }
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypeIdentity: FfiConverterRustBuffer {
    typealias SwiftType = Identity?

    public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
        guard let value = value else {
            writeInt(&buf, Int8(0))
            return
        }
        writeInt(&buf, Int8(1))
        FfiConverterTypeIdentity.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 FfiConverterTypeIdentity.read(from: &buf)
        default: throw UniffiInternalError.unexpectedOptionalTag
        }
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypeIssueRef: FfiConverterRustBuffer {
    typealias SwiftType = IssueRef?

    public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
        guard let value = value else {
            writeInt(&buf, Int8(0))
            return
        }
        writeInt(&buf, Int8(1))
        FfiConverterTypeIssueRef.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 FfiConverterTypeIssueRef.read(from: &buf)
        default: throw UniffiInternalError.unexpectedOptionalTag
        }
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypeItemPr: FfiConverterRustBuffer {
    typealias SwiftType = ItemPr?

    public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
        guard let value = value else {
            writeInt(&buf, Int8(0))
            return
        }
        writeInt(&buf, Int8(1))
        FfiConverterTypeItemPr.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 FfiConverterTypeItemPr.read(from: &buf)
        default: throw UniffiInternalError.unexpectedOptionalTag
        }
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypeItemRef: FfiConverterRustBuffer {
    typealias SwiftType = ItemRef?

    public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
        guard let value = value else {
            writeInt(&buf, Int8(0))
            return
        }
        writeInt(&buf, Int8(1))
        FfiConverterTypeItemRef.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 FfiConverterTypeItemRef.read(from: &buf)
        default: throw UniffiInternalError.unexpectedOptionalTag
        }
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypePageToken: FfiConverterRustBuffer {
    typealias SwiftType = PageToken?

    public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
        guard let value = value else {
            writeInt(&buf, Int8(0))
            return
        }
        writeInt(&buf, Int8(1))
        FfiConverterTypePageToken.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 FfiConverterTypePageToken.read(from: &buf)
        default: throw UniffiInternalError.unexpectedOptionalTag
        }
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterOptionTypeWorkItem: FfiConverterRustBuffer {
    typealias SwiftType = WorkItem?

    public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
        guard let value = value else {
            writeInt(&buf, Int8(0))
            return
        }
        writeInt(&buf, Int8(1))
        FfiConverterTypeWorkItem.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 FfiConverterTypeWorkItem.read(from: &buf)
        default: throw UniffiInternalError.unexpectedOptionalTag
        }
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
    typealias SwiftType = [String]

    public static func write(_ value: [String], into buf: inout [UInt8]) {
        let len = Int32(value.count)
        writeInt(&buf, len)
        for item in value {
            FfiConverterString.write(item, into: &buf)
        }
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String] {
        let len: Int32 = try readInt(&buf)
        var seq = [String]()
        seq.reserveCapacity(Int(len))
        for _ in 0 ..< len {
            seq.append(try FfiConverterString.read(from: &buf))
        }
        return seq
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeAbsorbGroup: FfiConverterRustBuffer {
    typealias SwiftType = [AbsorbGroup]

    public static func write(_ value: [AbsorbGroup], into buf: inout [UInt8]) {
        let len = Int32(value.count)
        writeInt(&buf, len)
        for item in value {
            FfiConverterTypeAbsorbGroup.write(item, into: &buf)
        }
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [AbsorbGroup] {
        let len: Int32 = try readInt(&buf)
        var seq = [AbsorbGroup]()
        seq.reserveCapacity(Int(len))
        for _ in 0 ..< len {
            seq.append(try FfiConverterTypeAbsorbGroup.read(from: &buf))
        }
        return seq
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeChangeRequest: FfiConverterRustBuffer {
    typealias SwiftType = [ChangeRequest]

    public static func write(_ value: [ChangeRequest], into buf: inout [UInt8]) {
        let len = Int32(value.count)
        writeInt(&buf, len)
        for item in value {
            FfiConverterTypeChangeRequest.write(item, into: &buf)
        }
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ChangeRequest] {
        let len: Int32 = try readInt(&buf)
        var seq = [ChangeRequest]()
        seq.reserveCapacity(Int(len))
        for _ in 0 ..< len {
            seq.append(try FfiConverterTypeChangeRequest.read(from: &buf))
        }
        return seq
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeCheck: FfiConverterRustBuffer {
    typealias SwiftType = [Check]

    public static func write(_ value: [Check], into buf: inout [UInt8]) {
        let len = Int32(value.count)
        writeInt(&buf, len)
        for item in value {
            FfiConverterTypeCheck.write(item, into: &buf)
        }
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Check] {
        let len: Int32 = try readInt(&buf)
        var seq = [Check]()
        seq.reserveCapacity(Int(len))
        for _ in 0 ..< len {
            seq.append(try FfiConverterTypeCheck.read(from: &buf))
        }
        return seq
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeIdentity: FfiConverterRustBuffer {
    typealias SwiftType = [Identity]

    public static func write(_ value: [Identity], into buf: inout [UInt8]) {
        let len = Int32(value.count)
        writeInt(&buf, len)
        for item in value {
            FfiConverterTypeIdentity.write(item, into: &buf)
        }
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Identity] {
        let len: Int32 = try readInt(&buf)
        var seq = [Identity]()
        seq.reserveCapacity(Int(len))
        for _ in 0 ..< len {
            seq.append(try FfiConverterTypeIdentity.read(from: &buf))
        }
        return seq
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeItemLink: FfiConverterRustBuffer {
    typealias SwiftType = [ItemLink]

    public static func write(_ value: [ItemLink], into buf: inout [UInt8]) {
        let len = Int32(value.count)
        writeInt(&buf, len)
        for item in value {
            FfiConverterTypeItemLink.write(item, into: &buf)
        }
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ItemLink] {
        let len: Int32 = try readInt(&buf)
        var seq = [ItemLink]()
        seq.reserveCapacity(Int(len))
        for _ in 0 ..< len {
            seq.append(try FfiConverterTypeItemLink.read(from: &buf))
        }
        return seq
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeLabel: FfiConverterRustBuffer {
    typealias SwiftType = [Label]

    public static func write(_ value: [Label], into buf: inout [UInt8]) {
        let len = Int32(value.count)
        writeInt(&buf, len)
        for item in value {
            FfiConverterTypeLabel.write(item, into: &buf)
        }
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Label] {
        let len: Int32 = try readInt(&buf)
        var seq = [Label]()
        seq.reserveCapacity(Int(len))
        for _ in 0 ..< len {
            seq.append(try FfiConverterTypeLabel.read(from: &buf))
        }
        return seq
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeLabelRef: FfiConverterRustBuffer {
    typealias SwiftType = [LabelRef]

    public static func write(_ value: [LabelRef], into buf: inout [UInt8]) {
        let len = Int32(value.count)
        writeInt(&buf, len)
        for item in value {
            FfiConverterTypeLabelRef.write(item, into: &buf)
        }
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [LabelRef] {
        let len: Int32 = try readInt(&buf)
        var seq = [LabelRef]()
        seq.reserveCapacity(Int(len))
        for _ in 0 ..< len {
            seq.append(try FfiConverterTypeLabelRef.read(from: &buf))
        }
        return seq
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeRepo: FfiConverterRustBuffer {
    typealias SwiftType = [Repo]

    public static func write(_ value: [Repo], into buf: inout [UInt8]) {
        let len = Int32(value.count)
        writeInt(&buf, len)
        for item in value {
            FfiConverterTypeRepo.write(item, into: &buf)
        }
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [Repo] {
        let len: Int32 = try readInt(&buf)
        var seq = [Repo]()
        seq.reserveCapacity(Int(len))
        for _ in 0 ..< len {
            seq.append(try FfiConverterTypeRepo.read(from: &buf))
        }
        return seq
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeStackItem: FfiConverterRustBuffer {
    typealias SwiftType = [StackItem]

    public static func write(_ value: [StackItem], into buf: inout [UInt8]) {
        let len = Int32(value.count)
        writeInt(&buf, len)
        for item in value {
            FfiConverterTypeStackItem.write(item, into: &buf)
        }
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [StackItem] {
        let len: Int32 = try readInt(&buf)
        var seq = [StackItem]()
        seq.reserveCapacity(Int(len))
        for _ in 0 ..< len {
            seq.append(try FfiConverterTypeStackItem.read(from: &buf))
        }
        return seq
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterSequenceTypeRequiredAccess: FfiConverterRustBuffer {
    typealias SwiftType = [RequiredAccess]

    public static func write(_ value: [RequiredAccess], into buf: inout [UInt8]) {
        let len = Int32(value.count)
        writeInt(&buf, len)
        for item in value {
            FfiConverterTypeRequiredAccess.write(item, into: &buf)
        }
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [RequiredAccess] {
        let len: Int32 = try readInt(&buf)
        var seq = [RequiredAccess]()
        seq.reserveCapacity(Int(len))
        for _ in 0 ..< len {
            seq.append(try FfiConverterTypeRequiredAccess.read(from: &buf))
        }
        return seq
    }
}

#if swift(>=5.8)
@_documentation(visibility: private)
#endif
fileprivate struct FfiConverterDictionaryStringString: FfiConverterRustBuffer {
    public static func write(_ value: [String: String], into buf: inout [UInt8]) {
        let len = Int32(value.count)
        writeInt(&buf, len)
        for (key, value) in value {
            FfiConverterString.write(key, into: &buf)
            FfiConverterString.write(value, into: &buf)
        }
    }

    public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String: String] {
        let len: Int32 = try readInt(&buf)
        var dict = [String: String]()
        dict.reserveCapacity(Int(len))
        for _ in 0..<len {
            let key = try FfiConverterString.read(from: &buf)
            let value = try FfiConverterString.read(from: &buf)
            dict[key] = value
        }
        return dict
    }
}
private let UNIFFI_RUST_FUTURE_POLL_READY: Int8 = 0
private let UNIFFI_RUST_FUTURE_POLL_MAYBE_READY: Int8 = 1

fileprivate let uniffiContinuationHandleMap = UniffiHandleMap<UnsafeContinuation<Int8, Never>>()

fileprivate func uniffiRustCallAsync<F, T>(
    rustFutureFunc: () -> UInt64,
    pollFunc: (UInt64, @escaping UniffiRustFutureContinuationCallback, UInt64) -> (),
    completeFunc: (UInt64, UnsafeMutablePointer<RustCallStatus>) -> F,
    freeFunc: (UInt64) -> (),
    liftFunc: (F) throws -> T,
    errorHandler: ((RustBuffer) throws -> Swift.Error)?
) async throws -> T {
    // Make sure to call uniffiEnsureInitialized() since future creation doesn't have a
    // RustCallStatus param, so doesn't use makeRustCall()
    uniffiEnsureInitialized()
    let rustFuture = rustFutureFunc()
    defer {
        freeFunc(rustFuture)
    }
    var pollResult: Int8;
    repeat {
        pollResult = await withUnsafeContinuation {
            pollFunc(
                rustFuture,
                uniffiFutureContinuationCallback,
                uniffiContinuationHandleMap.insert(obj: $0)
            )
        }
    } while pollResult != UNIFFI_RUST_FUTURE_POLL_READY

    return try liftFunc(makeRustCall(
        { completeFunc(rustFuture, $0) },
        errorHandler: errorHandler
    ))
}

// Callback handlers for an async calls.  These are invoked by Rust when the future is ready.  They
// lift the return value or error and resume the suspended function.
fileprivate func uniffiFutureContinuationCallback(handle: UInt64, pollResult: Int8) {
    if let continuation = try? uniffiContinuationHandleMap.remove(handle: handle) {
        continuation.resume(returning: pollResult)
    } else {
        print("uniffiFutureContinuationCallback invalid handle")
    }
}
/**
 * The crate (and FFI surface) version, surfaced to shells for the
 * compatibility-floor check described in ADR 0002.
 */
public func coreVersion() -> String {
    return try!  FfiConverterString.lift(try! rustCall() {
    uniffi_fjord_core_fn_func_core_version($0
    )
})
}
/**
 * The github.com configuration, for shells.
 */
public func githubComAuthConfig(oauthClientId: String?) -> GitHubAuthConfig {
    return try!  FfiConverterTypeGitHubAuthConfig.lift(try! rustCall() {
    uniffi_fjord_core_fn_func_github_com_auth_config(
        FfiConverterOptionString.lower(oauthClientId),$0
    )
})
}
/**
 * Phase 0 "hello-core" smoke command: proves a real call crosses the boundary
 * (direct crate for `fj`, UniFFI for the GUI shells) before any product logic
 * lands. Remove once a real workflow exists.
 */
public func hello(name: String) -> String {
    return try!  FfiConverterString.lift(try! rustCall() {
    uniffi_fjord_core_fn_func_hello(
        FfiConverterString.lower(name),$0
    )
})
}
/**
 * Check `token` against `GET /user` on `config`'s API before the shell
 * stores it. Reports who the token is, its kind, its expiry and any access
 * it is known to lack. A rejected token is `Auth`; nothing is stored.
 */
public func validateGithubToken(config: GitHubAuthConfig, token: String, cancel: CancelFlag)async throws  -> TokenValidation {
    return
        try  await uniffiRustCallAsync(
            rustFutureFunc: {
                uniffi_fjord_core_fn_func_validate_github_token(FfiConverterTypeGitHubAuthConfig.lower(config),FfiConverterString.lower(token),FfiConverterTypeCancelFlag.lower(cancel)
                )
            },
            pollFunc: ffi_fjord_core_rust_future_poll_rust_buffer,
            completeFunc: ffi_fjord_core_rust_future_complete_rust_buffer,
            freeFunc: ffi_fjord_core_rust_future_free_rust_buffer,
            liftFunc: FfiConverterTypeTokenValidation.lift,
            errorHandler: FfiConverterTypeForgeCallError.lift
        )
}

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 var initializationResult: InitializationResult = {
    // Get the bindings contract version from our ComponentInterface
    let bindings_contract_version = 26
    // Get the scaffolding contract version by calling the into the dylib
    let scaffolding_contract_version = ffi_fjord_core_uniffi_contract_version()
    if bindings_contract_version != scaffolding_contract_version {
        return InitializationResult.contractVersionMismatch
    }
    if (uniffi_fjord_core_checksum_func_core_version() != 30916) {
        return InitializationResult.apiChecksumMismatch
    }
    if (uniffi_fjord_core_checksum_func_github_com_auth_config() != 61573) {
        return InitializationResult.apiChecksumMismatch
    }
    if (uniffi_fjord_core_checksum_func_hello() != 46069) {
        return InitializationResult.apiChecksumMismatch
    }
    if (uniffi_fjord_core_checksum_func_validate_github_token() != 58466) {
        return InitializationResult.apiChecksumMismatch
    }
    if (uniffi_fjord_core_checksum_method_cancelflag_cancel() != 4402) {
        return InitializationResult.apiChecksumMismatch
    }
    if (uniffi_fjord_core_checksum_method_cancelflag_is_cancelled() != 55378) {
        return InitializationResult.apiChecksumMismatch
    }
    if (uniffi_fjord_core_checksum_method_providerhandle_account() != 14674) {
        return InitializationResult.apiChecksumMismatch
    }
    if (uniffi_fjord_core_checksum_method_providerhandle_check_status() != 15990) {
        return InitializationResult.apiChecksumMismatch
    }
    if (uniffi_fjord_core_checksum_method_providerhandle_diff() != 11488) {
        return InitializationResult.apiChecksumMismatch
    }
    if (uniffi_fjord_core_checksum_method_providerhandle_list_pull_requests() != 54585) {
        return InitializationResult.apiChecksumMismatch
    }
    if (uniffi_fjord_core_checksum_method_providerhandle_list_repositories() != 55707) {
        return InitializationResult.apiChecksumMismatch
    }
    if (uniffi_fjord_core_checksum_method_providerhandle_pull_request() != 48771) {
        return InitializationResult.apiChecksumMismatch
    }
    if (uniffi_fjord_core_checksum_method_tokenstore_token() != 11277) {
        return InitializationResult.apiChecksumMismatch
    }
    if (uniffi_fjord_core_checksum_constructor_cancelflag_new() != 46060) {
        return InitializationResult.apiChecksumMismatch
    }
    if (uniffi_fjord_core_checksum_constructor_providerhandle_new() != 26663) {
        return InitializationResult.apiChecksumMismatch
    }

    uniffiCallbackInitTokenStore()
    return InitializationResult.ok
}()

private func uniffiEnsureInitialized() {
    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