@@ -138,7 +138,7 @@ extension CSVReader {
138138 /// - returns: Structure containing all CSV rows and optionally a the CSV headers.
139139 public static func decode< S> ( input: S , configuration: Configuration = . init( ) ) throws -> FileView where S: StringProtocol {
140140 let reader = try CSVReader ( input: input, configuration: configuration)
141- return try CSVReader . decode ( with : reader )
141+ return try reader . _decodeFile ( )
142142 }
143143
144144 /// Reads a blob of data using the encoding provided as argument and returns the CSV headers (if any) and all the CSV records.
@@ -148,7 +148,7 @@ extension CSVReader {
148148 /// - returns: Structure containing all CSV rows and optionally a the CSV headers.
149149 public static func decode( input: Data , configuration: Configuration = . init( ) ) throws -> FileView {
150150 let reader = try CSVReader ( input: input, configuration: configuration)
151- return try CSVReader . decode ( with : reader )
151+ return try reader . _decodeFile ( )
152152 }
153153
154154 /// Reads a CSV file using the provided encoding and returns the CSV headers (if any) and all the CSV records.
@@ -158,7 +158,7 @@ extension CSVReader {
158158 /// - returns: Structure containing all CSV rows and optionally a the CSV headers.
159159 public static func decode( input: URL , configuration: Configuration = . init( ) ) throws -> FileView {
160160 let reader = try CSVReader ( input: input, configuration: configuration)
161- return try CSVReader . decode ( with : reader )
161+ return try reader . _decodeFile ( )
162162 }
163163
164164 /// Reads a CSV file using the provided encoding and returns the CSV headers (if any) and all the CSV records.
@@ -168,7 +168,7 @@ extension CSVReader {
168168 /// - returns: Structure containing all CSV rows and optionally a the CSV headers.
169169 public static func decode( input: InputStream , configuration: Configuration = . init( ) ) throws -> FileView {
170170 let reader = try CSVReader ( input: input, configuration: configuration)
171- return try CSVReader . decode ( with : reader )
171+ return try reader . _decodeFile ( )
172172 }
173173}
174174
@@ -229,7 +229,7 @@ private extension CSVReader {
229229 /// - parameter stream: The stream to be parsed.
230230 /// - parameter configuration: Recipe detailing how to parse the CSV data (i.e. encoding, delimiters, etc.).
231231 /// - throws: `CSVError<CSVReader>` exclusively.
232- convenience init ( stream: InputStream , configuration: Configuration ) throws {
232+ private convenience init ( stream: InputStream , configuration: Configuration ) throws {
233233 assert ( !configuration. presample && stream. streamStatus == . notOpen)
234234 stream. open ( )
235235
@@ -254,15 +254,15 @@ private extension CSVReader {
254254 /// - parameter reader: The `CSVReader` used for parsing a CSV input.
255255 /// - throws: `CSVError<CSVReader>` exclusively.
256256 /// - returns: Structure containing all CSV rows and optionally a the CSV headers.
257- static func decode ( with reader : CSVReader ) throws -> FileView {
258- let lookup = try reader . headers. lookupDictionary ( onCollision: Error . _invalidHashableHeader)
257+ private func _decodeFile ( ) throws -> FileView {
258+ let lookup = try self . headers. lookupDictionary ( onCollision: Error . _invalidHashableHeader)
259259
260260 var result : [ [ String ] ] = . init( )
261- while let row = try reader . readRow ( ) {
261+ while let row = try self . readRow ( ) {
262262 result. append ( row)
263263 }
264264
265- return . init( headers: reader . headers, rows: result, lookup: lookup)
265+ return . init( headers: self . headers, rows: result, lookup: lookup)
266266 }
267267}
268268
0 commit comments