Renamed async CSV decoder types
This commit is contained in:
parent
0184ab3c2a
commit
2105cb0330
|
@ -102,7 +102,7 @@ public final class CSVSyncDecoder {
|
|||
var result: [D] = []
|
||||
result.reserveCapacity(data.lazy.split(separator: "\n").count)
|
||||
|
||||
let decoder = _CSVAsyncDecoder(decoding: type, path: [], decodingOptions: self.decodingOptions) { decoded in
|
||||
let decoder = AsyncDecoder(decoding: type, path: [], decodingOptions: self.decodingOptions) { decoded in
|
||||
guard let typed = decoded as? D else {
|
||||
assertionFailure("Passed incompatible value into decoding completion callback")
|
||||
return
|
||||
|
@ -120,7 +120,7 @@ public final class CSVAsyncDecoder {
|
|||
internal var length: Int
|
||||
internal var decoding: Decodable.Type
|
||||
internal var decodingOptions: CSVCodingOptions
|
||||
private var rowDecoder: _CSVAsyncDecoder
|
||||
private var rowDecoder: AsyncDecoder
|
||||
|
||||
internal init<D>(decoding: D.Type, onInstance: @escaping (D) -> (), length: Int, decodingOptions: CSVCodingOptions)
|
||||
where D: Decodable
|
||||
|
@ -136,7 +136,7 @@ public final class CSVAsyncDecoder {
|
|||
self.length = length
|
||||
self.decoding = decoding
|
||||
self.decodingOptions = decodingOptions
|
||||
self.rowDecoder = _CSVAsyncDecoder(
|
||||
self.rowDecoder = AsyncDecoder(
|
||||
decoding: D.self,
|
||||
path: [],
|
||||
decodingOptions: decodingOptions,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
internal final class _CSVAsyncDecoder: Decoder {
|
||||
internal final class AsyncDecoder: Decoder {
|
||||
internal enum Storage {
|
||||
case none
|
||||
case singleValue([UInt8])
|
||||
|
@ -50,7 +50,7 @@ internal final class _CSVAsyncDecoder: Decoder {
|
|||
))
|
||||
}
|
||||
|
||||
let container = try _AsyncKeyedDecoder<Key>(path: self.codingPath, decoder: self)
|
||||
let container = try AsyncKeyedDecoder<Key>(path: self.codingPath, decoder: self)
|
||||
return KeyedDecodingContainer(container)
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ internal final class _CSVAsyncDecoder: Decoder {
|
|||
))
|
||||
}
|
||||
|
||||
return try _AsyncSingleValueDecoder(path: self.codingPath, decoder: self)
|
||||
return try AsyncSingleValueDecoder(path: self.codingPath, decoder: self)
|
||||
}
|
||||
|
||||
func decode(_ data: [UInt8], length: Int)throws {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
internal final class _AsyncKeyedDecoder<K>: KeyedDecodingContainerProtocol where K: CodingKey {
|
||||
internal final class AsyncKeyedDecoder<K>: KeyedDecodingContainerProtocol where K: CodingKey {
|
||||
internal var codingPath: [CodingKey]
|
||||
internal var decoder: _CSVAsyncDecoder
|
||||
internal var decoder: AsyncDecoder
|
||||
private var data: [String: [UInt8]]
|
||||
|
||||
internal init(path: [CodingKey], decoder: _CSVAsyncDecoder)throws {
|
||||
internal init(path: [CodingKey], decoder: AsyncDecoder)throws {
|
||||
self.decoder = decoder
|
||||
self.codingPath = path
|
||||
|
||||
|
@ -99,7 +99,7 @@ internal final class _AsyncKeyedDecoder<K>: KeyedDecodingContainerProtocol where
|
|||
|
||||
public func decode<T>(_ type: T.Type, forKey key: K) throws -> T where T : Decodable {
|
||||
let bytes = try self.bytes(for: key, type: type)
|
||||
let decoder = _CSVAsyncDecoder(
|
||||
let decoder = AsyncDecoder(
|
||||
decoding: self.decoder.decoding,
|
||||
path: self.codingPath + [key],
|
||||
data: .singleValue(bytes),
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
internal final class _AsyncSingleValueDecoder: SingleValueDecodingContainer {
|
||||
internal final class AsyncSingleValueDecoder: SingleValueDecodingContainer {
|
||||
var codingPath: [CodingKey]
|
||||
var decoder: _CSVAsyncDecoder
|
||||
var decoder: AsyncDecoder
|
||||
var bytes: [UInt8]
|
||||
|
||||
internal init(path: [CodingKey], decoder: _CSVAsyncDecoder)throws {
|
||||
internal init(path: [CodingKey], decoder: AsyncDecoder)throws {
|
||||
self.decoder = decoder
|
||||
self.codingPath = path
|
||||
|
||||
|
@ -68,7 +68,7 @@ internal final class _AsyncSingleValueDecoder: SingleValueDecodingContainer {
|
|||
}
|
||||
|
||||
func decode<T>(_ type: T.Type) throws -> T where T : Decodable {
|
||||
let decoder = _CSVAsyncDecoder(
|
||||
let decoder = AsyncDecoder(
|
||||
decoding: self.decoder.decoding,
|
||||
path: self.codingPath,
|
||||
data: .singleValue(self.bytes),
|
||||
|
|
Loading…
Reference in New Issue