Add export and import

This commit is contained in:
Christoph Hagen
2023-08-21 09:16:45 +02:00
parent 911fc0c8f8
commit cd37df22bf
8 changed files with 160 additions and 19 deletions

View File

@ -1,12 +1,5 @@
import Foundation
struct Titled<Content> {
let title: String
let items: [Content]
}
struct CVInfo {
let language: String
@ -47,3 +40,7 @@ extension CVInfo: Hashable {
hasher.combine(language)
}
}
extension CVInfo: Codable {
}

View File

@ -16,3 +16,7 @@ struct CareerStation: Identifiable {
title + time + location
}
}
extension CareerStation: Codable {
}

View File

@ -10,3 +10,7 @@ struct Publication: Identifiable {
title + venue
}
}
extension Publication: Codable {
}

View File

@ -11,3 +11,26 @@ struct SkillsSet: Identifiable {
entries.joined()
}
}
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)
}
}

View File

@ -0,0 +1,12 @@
import Foundation
struct Titled<Content> {
let title: String
let items: [Content]
}
extension Titled: Codable where Content: Codable {
}

View File

@ -20,3 +20,7 @@ struct TopInfo {
let github: String
}
extension TopInfo: Codable {
}