Sesame-iOS/Sesame/Common/ConnectionStrategy.swift
2023-12-12 17:33:42 +01:00

28 lines
702 B
Swift

import Foundation
import CryptoKit
enum ConnectionStrategy: Int, CaseIterable, Identifiable {
case local = 0
case remote = 1
case localFirst = 2
case remoteFirst = 3
var id: Int { rawValue }
var transmissionTypes: [TransmissionType] {
switch self {
case .local: return [.overLocalWifi]
case .localFirst: return [.overLocalWifi, .throughServer]
case .remote: return [.throughServer]
case .remoteFirst: return [.throughServer, .overLocalWifi]
}
}
}
extension ConnectionStrategy: CustomStringConvertible {
var description: String {
transmissionTypes.map { $0.displayName }.joined(separator: "+")
}
}