Skip to content

Conversation

@hello-im-szymon
Copy link
Collaborator

This allows for a bit less strict decoders. For example:

private struct ImageDecoder: ConcreteTypeDecoder {

    enum DecodingError: Error {
        case invalidData
    }

    func decode(_ data: Data) throws -> UIImage {
        guard let image = UIImage(data: data) else {
            throw DecodingError.invalidData
        }
        return image
    }

}

The API is not changed for existing clients.

// For legacy reasons
public typealias DataDecoder = AnyTypeDecoder

public protocol ConcreteTypeDecoder {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about the naming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant