Closed tal closed 6 years ago
@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
I'm not sure if this is an oversight, but there's no default conformance for
Codable
toReadableWriteable
.This conformance would allow for
File<DataType: ReadableWritable>
to work with anyCodable
and appears to be the intent as listed in the readme.