private enum CodingKeys: String, CodingKey {
case {{ tag_ident }} = "{{ tag_wire }}"
case {{ content_ident }} = "{{ content_wire }}"
}
{% if payload_key_cases %}
private enum PayloadKeys: String, CodingKey {
{{ payload_key_cases }} }
{% endif %}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
let tag = try container.decode(String.self, forKey: .{{ tag_ident }})
switch tag {
{{ decode_cases }} default:
throw DecodingError.dataCorruptedError(
forKey: .{{ tag_ident }},
in: container,
debugDescription: "Unknown {{ enum_name }} tag: \(tag)"
)
}
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
switch self {
{{ encode_cases }} }
}