CHResume/ResumeBuilder/Data/SkillsSet.swift

37 lines
946 B
Swift
Raw Permalink Normal View History

2023-08-18 22:47:24 +02:00
import Foundation
import SFSafeSymbols
struct SkillsSet: Identifiable {
let systemSymbol: SFSymbol
let entries: [String]
var id: String {
entries.joined()
}
}
2023-08-21 09:16:45 +02:00
extension SkillsSet: Decodable {
private enum CodingKeys: String, CodingKey {
case systemSymbol
case entries
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let rawSymbol = try container.decode(String.self, forKey: .systemSymbol)
self.systemSymbol = .init(rawValue: rawSymbol)
self.entries = try container.decode([String].self, forKey: .entries)
}
}
extension SkillsSet: Encodable {
func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(systemSymbol.rawValue, forKey: .systemSymbol)
try container.encode(entries, forKey: .entries)
}
}