Conform to EntityIdentifierConvertible
magnusburton opened this issue · 1 comments
magnusburton commented
I tried implementing conformity to EntityIdentifierConvertible
in AppIntents, but I couldn't make it work. I'd like to be able to do the following:
import Tagged
struct Route: Identifiable, Codable, Sendable {
typealias ID = Tagged< Route, String>
let id: ID
}
import AppIntents
struct RouteEntity: AppEntity, Identifiable {
var id: Route.ID
var name: String
// ...
}
Now, as a work-around I define id in the entity as Route.ID.RawValue
but that defeats the purpose a bit. What do you think?
mbrandonw commented
Does it help if you conditionally make Tagged
conform to EntityIdentifierConvertible
:
extension Tagged: EntityIdentifierConvertible where RawValue == String {
public var entityIdentifierString: String {
self.rawValue
}
public static func entityIdentifier(for entityIdentifierString: String) -> Tagged<Tag, RawValue>? {
Tagged(entityIdentifierString)
}
}
If this is the correct thing for us to do we could include it in the library.
Also, this is not really an issue with a library, and so I am going to convert this to a discussion. Feel free to continue the conversation over there.