Hi! I've got a fun, maybe simple question for you about using Cereal with an enum:
I've got a small class and an enum, which look like:
enum UploadEnum {
case Sending
case Sent
case Failed(error: NSError)
}
class DataClass {
let name: String
let upload: UploadEnum
}
I want to encode DataClass with Cereal, but… I don't know how, because of UploadEnum.
With other enums without associated types, I've encoded the enum's rawValue, and then decoded it with the enum's .init(rawValue: <>) initializer.
Can you think of any simple ways to encode UploadEnum? I can think of some invasive approaches which require changing the enum, but I'm seeking alternatives.
Hi! I've got a fun, maybe simple question for you about using Cereal with an enum:
I've got a small class and an enum, which look like:
I want to encode DataClass with Cereal, but… I don't know how, because of UploadEnum.
With other enums without associated types, I've encoded the enum's
rawValue
, and then decoded it with the enum's.init(rawValue: <>)
initializer.Can you think of any simple ways to encode
UploadEnum
? I can think of some invasive approaches which require changing the enum, but I'm seeking alternatives.