Sesame-iOS/Sesame/Common/ConnectionStrategy.swift

28 lines
704 B
Swift
Raw Normal View History

2023-08-14 10:39:29 +02:00
import Foundation
2023-12-12 17:33:42 +01:00
import CryptoKit
2023-08-14 10:39:29 +02:00
2023-12-12 17:33:42 +01:00
enum ConnectionStrategy: Int, CaseIterable, Identifiable {
case local = 0
case remote = 1
case localFirst = 2
case remoteFirst = 3
2023-08-14 10:39:29 +02:00
2023-12-12 17:33:42 +01:00
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 {
2023-12-20 19:04:48 +01:00
transmissionTypes.map { $0.displayName }.joined(separator: " + ")
2023-12-12 17:33:42 +01:00
}
2023-08-14 10:39:29 +02:00
}