Codable doesn't conform to ReadableWritable
tal opened this issue · 1 comments
tal commented
I'm not sure if this is an oversight, but there's no default conformance for Codable
to ReadableWriteable
.
This conformance would allow for File<DataType: ReadableWritable>
to work with any Codable
and appears to be the intent as listed in the readme.
phimage commented
@tal If you have any idea of elegant implementation, you can propose it, or you can also PR
With the current implementation you can do that
// Just to be shorter if used many times, and this implement Codable using JSON encoder/decoder
typealias JSONReadableWritable = JSONWritable & JSONReadable
struct Test: JSONReadableWritable {
var test: String
}
// then you can use File<Test> or make an alias
typealias TestFile = File<Test> // File need a concrete type, no protocol
The encoder and decoder used are static variable in FileKit
I will add in FileKit JSONReadableWritable
and PropertyListReadableWritable
doc edited for that https://github.com/nvzqz/FileKit/blob/develop/README.md#encodabledecodable