make ApkIndexDependency conform to ApkIndexRequirementRef

dunno if this is necessary for the graph to work but we'll see
This commit is contained in:
2024-11-10 21:00:07 +11:00
parent d6b0acf807
commit e7fc47d640
6 changed files with 17 additions and 28 deletions

View File

@ -7,7 +7,7 @@ protocol ApkIndexRequirementRef: Equatable, Hashable {
var name: String { get }
var invert: Bool { get }
init(extract: String) throws(ApkRequirement.ParseError)
init(name: String, version spec: ApkVersionSpecification)
func satisfied(by other: ApkIndexPackage) -> Bool
}
@ -16,18 +16,11 @@ extension ApkIndexRequirementRef {
var invert: Bool { false }
func satisfied(by _: ApkIndexPackage) -> Bool { true }
static func == (lhs: Self, rhs: Self) -> Bool {
return !(lhs.name != rhs.name && !lhs.invert)
}
func hash(into hasher: inout Hasher) {
self.name.hash(into: &hasher)
}
static func extract<T: ApkIndexRequirementRef>(_ blob: String) throws(ApkRequirement.ParseError) -> [T] {
return try blob.components(separatedBy: " ")
.map { token throws(ApkRequirement.ParseError) in
try .init(extract: token)
let (name, versionSpec) = try ApkRequirement.extract(blob: token)
return .init(name: name, version: versionSpec)
}
}
}