Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930import Foundation
public struct SetupCatalog: Sendable, Equatable, Codable { public var setups: [SavedSetup]
public init(setups: [SavedSetup] = []) throws { self.setups = setups try validate() }
public func validate() throws { var ids: Set<UUID> = [] var names: Set<String> = [] for setup in setups { try setup.validate() guard ids.insert(setup.id).inserted else { throw SavedSetupError.duplicateID(setup.id) } guard names.insert(setup.normalizedName).inserted else { throw SavedSetupError.duplicateName(setup.name) } } }
private enum CodingKeys: String, CodingKey { case setups }
public init(from decoder: any Decoder) throws { let values = try decoder.container(keyedBy: CodingKeys.self) try self.init(setups: values.decode([SavedSetup].self, forKey: .setups)) }}