mirror of
https://github.com/apple/swift-http-structured-headers
synced 2026-11-25 04:47:48 +00:00
Add support for encoding/decoding binary data
This commit is contained in:
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
|
||||
|
||||
struct TopLevelListDecoder<BaseData: RandomAccessCollection> where BaseData.Element == UInt8, BaseData.SubSequence: Hashable {
|
||||
@@ -64,7 +65,13 @@ extension TopLevelListDecoder: UnkeyedDecodingContainer {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
mutating func nestedContainer<NestedKey>(keyedBy type: NestedKey.Type) throws -> KeyedDecodingContainer<NestedKey> where NestedKey : CodingKey {
|
||||
|
||||
Reference in new issue
Block a user