Skip to content

Commit 7cef543

Browse files
committed
Refactor AttributeGraphVendor from enum to RawRepresentable struct
1 parent 91dd6f1 commit 7cef543

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

Sources/OpenAttributeGraphShims/GraphShims.swift

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,26 @@
22
// GraphShims.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

0 commit comments

Comments
 (0)