Hi there. We are <SKIE> in our project and I am wo...
# touchlab-tools
z
Hi there. We are SKIE in our project and I am wondering if it is possible to conform the class/struct from the Shared part to
Codable
?
m
I believe you can only do it on swift side using a propertyWrapper
Something like
Copy code
@propertyWrapper
struct CodableMimeType {
    var wrappedValue: SharedCode.MimeType
}

extension CodableMimeType: Codable {

    public init(from decoder: Decoder) throws {
        let container = try decoder.singleValueContainer()
        let rawString = try container.decode(String.self)

        wrappedValue = SharedCode.MimeType.companion.of(value: rawString)
    }

    public func encode(to encoder: Encoder) throws {
        var container = encoder.singleValueContainer()

        try container.encode(wrappedValue.description())
    }
}
z
Thank you 😄
t
You might also be able to use SKIE's undocumented custom Swift code feature