Files
darwin-apk/Sources/apk/Version/ApkVersionSpecification.swift

50 lines
1.1 KiB
Swift
Raw Normal View History

2024-11-10 17:51:53 +11:00
/*
* darwin-apk © 2024 Gay Pizza Specifications
* SPDX-License-Identifier: Apache-2.0
*/
enum ApkVersionSpecification: Equatable, Hashable, Sendable {
case any(invert: Bool = false)
case constraint(invert: Bool = false, op: Operator, version: String)
}
extension ApkVersionSpecification {
enum Operator: Equatable, Sendable {
case equals
case fuzzyEquals
case greater
case less
case greaterEqual
case lessEqual
case greaterFuzzy
case lessFuzzy
}
}
2025-07-06 17:12:52 +10:00
internal extension ApkVersionSpecification {
@inlinable var conflict: Bool {
switch self {
case .any(invert: true), .constraint(invert: true, _, _):
return true
default:
return false
}
}
}
extension ApkVersionSpecification.Operator: CustomStringConvertible {
var description: String {
switch self {
//case .checksum: "><"
case .lessEqual: "<="
case .greaterEqual: ">="
case .lessFuzzy: "<~"
case .greaterFuzzy: ">~"
case .equals: "="
case .less: "<"
case .greater: ">"
case .fuzzyEquals: "~"
}
}
}