import Foundation #if canImport(FoundationNetworking) import FoundationNetworking #endif public enum MusicBrainzError: Error { case badURL case badServerResponse(Int) case decodingError(Error) case coordinator(Error) } // MARK: - Generic Support internal struct DynamicCodingKey: CodingKey { var stringValue: String var intValue: Int? init?(stringValue: String) { self.stringValue = stringValue } init?(intValue: Int) { return nil } } public enum MusicBrainzEntity: String, Sendable { case area case artist case event case instrument case label case place case recording case release case releaseGroup = "release-group" case series case work case url public var responseKey: String { switch self { case .series: return "series" default: return "\(self.rawValue)s" } } } public struct MusicBrainzEntityType: Sendable { public let entity: MusicBrainzEntity public static var area: MusicBrainzEntityType { .init(entity: .area) } public static var artist: MusicBrainzEntityType { .init(entity: .artist) } public static var event: MusicBrainzEntityType { .init(entity: .event) } public static var instrument: MusicBrainzEntityType { .init(entity: .instrument) } public static var label: MusicBrainzEntityType