Add support for encoding/decoding binary data

This commit is contained in:
Cory Benfield committed 2020-07-16 13:16:20 +01:00
1 parent 5aaca631da
commit b797a6ff50
11 files changed
+211 -12

No files matched your search

@@ -11,6 +11,7 @@
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import Foundation
import StructuredHeaders
private let keyedItemDecoderSupportedKeys = ["item", "parameters"]
@@ -52,7 +53,13 @@ extension KeyedItemDecoder: KeyedDecodingContainerProtocol {
defer {
self.decoder.pop()
}
return try type.init(from: self.decoder)
if type is Data.Type {
let container = try self.decoder.singleValueContainer()
return try container.decode(Data.self) as! T
} else {
return try type.init(from: self.decoder)
}
}
func nestedContainer<NestedKey: CodingKey>(keyedBy type: NestedKey.Type, forKey key: Key) throws -> KeyedDecodingContainer<NestedKey> {