29 lines
556 B
Swift
29 lines
556 B
Swift
public struct NutrientLevels: Sendable, Codable {
|
|
|
|
public enum Level: String, Sendable, Codable {
|
|
case high, moderate, low
|
|
}
|
|
|
|
public var fat: Level? = nil
|
|
public var salt: Level? = nil
|
|
public var saturatedFat: Level? = nil
|
|
public var sugars: Level? = nil
|
|
|
|
public enum CodingKeys: String, CodingKey {
|
|
case fat
|
|
case salt
|
|
case saturatedFat = "saturated-fat"
|
|
case sugars
|
|
}
|
|
|
|
public subscript(_ key: CodingKeys) -> Level? {
|
|
switch key {
|
|
case .fat: fat
|
|
case .salt: salt
|
|
case .saturatedFat: saturatedFat
|
|
case .sugars: sugars
|
|
}
|
|
}
|
|
|
|
}
|