Skip to content

Commit 30d5d34

Browse files
authored
Refactor AttributeGraphVendor to RawRepresentable struct (#222)
1 parent 91dd6f1 commit 30d5d34

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

Sources/OpenAttributeGraphShims/GraphShims.swift renamed to Sources/OpenAttributeGraphShims/OAGShims.swift

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
//
2-
// GraphShims.swift
2+
// AGShims.swift
33
// OpenAttributeGraphShims
44

5-
public enum AttributeGraphVendor: String {
6-
case oag = "org.OpenSwiftUIProject.OpenAttributeGraph"
7-
case ag = "com.apple.AttributeGraph"
8-
case compute = "dev.incrematic.compute"
5+
/// A type that identifies the underlying attribute graph implementation vendor.
6+
///
7+
/// Use `attributeGraphVendor` to check which vendor is active at runtime.
8+
public struct AttributeGraphVendor: RawRepresentable, Hashable, CaseIterable {
9+
public let rawValue: String
10+
11+
public init(rawValue: String) {
12+
self.rawValue = rawValue
13+
}
14+
15+
/// OpenAttributeGraph — the open-source implementation by OpenSwiftUIProject.
16+
public static let oag = AttributeGraphVendor(rawValue: "org.OpenSwiftUIProject.OpenAttributeGraph")
17+
18+
/// Apple's private AttributeGraph framework.
19+
public static let ag = AttributeGraphVendor(rawValue: "com.apple.AttributeGraph")
20+
21+
/// An incremental computation library for Swift by @jcmosc
22+
public static let compute = AttributeGraphVendor(rawValue: "dev.incrematic.compute")
23+
24+
public static var allCases: [AttributeGraphVendor] { [.oag, .ag, .compute] }
925
}
1026

1127
#if OPENATTRIBUTEGRAPH_COMPUTE

Tests/OpenAttributeGraphCompatibilityTests/GraphShims.swift renamed to Tests/OpenAttributeGraphCompatibilityTests/OAGShims.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// GraphShims.swift
2+
// OAGShims.swift
33
// OpenAttributeGraphCompatibilityTests
44

55
#if OPENATTRIBUTEGRAPH

0 commit comments

Comments
 (0)