Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Swift 5.7 warnings. #52

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions sources/declarative/decodable/Decoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension CSVDecoder {
/// Returns a value of the type you specify, decoded from a CSV file (given as a `Data` blob).
/// - parameter type: The type of the value to decode from the supplied file.
/// - parameter data: The data blob representing a CSV file.
open func decode<T:Decodable>(_ type: T.Type, from data: Data) throws -> T {
public func decode<T:Decodable>(_ type: T.Type, from data: Data) throws -> T {
let reader = try CSVReader(input: data, configuration: self._configuration.readerConfiguration)
return try withExtendedLifetime(ShadowDecoder.Source(reader: reader, configuration: self._configuration, userInfo: self.userInfo)) {
try T(from: ShadowDecoder(source: .passUnretained($0), codingPath: []))
Expand All @@ -44,7 +44,7 @@ extension CSVDecoder {
/// Returns a value of the type you specify, decoded from a CSV file (given as a `String`).
/// - parameter type: The type of the value to decode from the supplied file.
/// - parameter string: A Swift string representing a CSV file.
open func decode<T:Decodable>(_ type: T.Type, from string: String) throws -> T {
public func decode<T:Decodable>(_ type: T.Type, from string: String) throws -> T {
let reader = try CSVReader(input: string, configuration: self._configuration.readerConfiguration)
return try withExtendedLifetime(ShadowDecoder.Source(reader: reader, configuration: self._configuration, userInfo: self.userInfo)) {
try T(from: ShadowDecoder(source: .passUnretained($0), codingPath: []))
Expand All @@ -54,7 +54,7 @@ extension CSVDecoder {
/// Returns a value of the type you specify, decoded from a CSV file (being pointed by the url).
/// - parameter type: The type of the value to decode from the supplied file.
/// - parameter url: The URL pointing to the file to decode.
open func decode<T:Decodable>(_ type: T.Type, from url: URL) throws -> T {
public func decode<T:Decodable>(_ type: T.Type, from url: URL) throws -> T {
let reader = try CSVReader(input: url, configuration: self._configuration.readerConfiguration)
return try withExtendedLifetime(ShadowDecoder.Source(reader: reader, configuration: self._configuration, userInfo: self.userInfo)) {
try T(from: ShadowDecoder(source: .passUnretained($0), codingPath: []))
Expand All @@ -64,7 +64,7 @@ extension CSVDecoder {
/// Returns a value of the type you specify, decoded from a CSV file (provided by the input stream).
/// - parameter type: The type of the value to decode from the supplied file.
/// - parameter stream: The input stream providing the raw bytes.
open func decode<T:Decodable>(_ type: T.Type, from stream: InputStream) throws -> T {
public func decode<T:Decodable>(_ type: T.Type, from stream: InputStream) throws -> T {
let reader = try CSVReader(input: stream, configuration: self._configuration.readerConfiguration)
return try withExtendedLifetime(ShadowDecoder.Source(reader: reader, configuration: self._configuration, userInfo: self.userInfo)) {
try T(from: ShadowDecoder(source: .passUnretained($0), codingPath: []))
Expand All @@ -76,7 +76,7 @@ extension CSVDecoder {
/// Returns a sequence for decoding row-by-row from a CSV file (given as a `Data` blob).
/// - parameter data: The data blob representing a CSV file.
/// - throws: `CSVError<CSVReader>` exclusively.
open func lazy(from data: Data) throws -> Lazy {
public func lazy(from data: Data) throws -> Lazy {
let reader = try CSVReader(input: data, configuration: self._configuration.readerConfiguration)
let source = ShadowDecoder.Source(reader: reader, configuration: self._configuration, userInfo: self.userInfo)
return Lazy(source: source)
Expand All @@ -85,7 +85,7 @@ extension CSVDecoder {
/// Returns a sequence for decoding row-by-row from a CSV file (given as a `String`).
/// - parameter string: A Swift string representing a CSV file.
/// - throws: `CSVError<CSVReader>` exclusively.
open func lazy(from string: String) throws -> Lazy {
public func lazy(from string: String) throws -> Lazy {
let reader = try CSVReader(input: string, configuration: self._configuration.readerConfiguration)
let source = ShadowDecoder.Source(reader: reader, configuration: self._configuration, userInfo: self.userInfo)
return Lazy(source: source)
Expand All @@ -94,7 +94,7 @@ extension CSVDecoder {
/// Returns a sequence for decoding row-by-row from a CSV file (being pointed by `url`).
/// - parameter url: The URL pointing to the file to decode.
/// - throws: `CSVError<CSVReader>` exclusively.
open func lazy(from url: URL) throws -> Lazy {
public func lazy(from url: URL) throws -> Lazy {
let reader = try CSVReader(input: url, configuration: self._configuration.readerConfiguration)
let source = ShadowDecoder.Source(reader: reader, configuration: self._configuration, userInfo: self.userInfo)
return Lazy(source: source)
Expand Down
12 changes: 6 additions & 6 deletions sources/declarative/encodable/Encoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extension CSVEncoder {
/// - parameter value: The value to encode as CSV.
/// - parameter type: The Swift type for a data blob.
/// - returns: `Data` blob with the CSV representation of `value`.
open func encode<T:Encodable>(_ value: T, into type: Data.Type) throws -> Data {
public func encode<T:Encodable>(_ value: T, into type: Data.Type) throws -> Data {
let writer = try CSVWriter(configuration: self._configuration.writerConfiguration)
try withExtendedLifetime(try ShadowEncoder.Sink(writer: writer, configuration: self._configuration, userInfo: self.userInfo)) {
try value.encode(to: ShadowEncoder(sink: .passUnretained($0), codingPath: []))
Expand All @@ -48,7 +48,7 @@ extension CSVEncoder {
/// - parameter value: The value to encode as CSV.
/// - parameter type: The Swift type for a string.
/// - returns: `String` with the CSV representation of `value`.
open func encode<T:Encodable>(_ value: T, into type: String.Type) throws -> String {
public func encode<T:Encodable>(_ value: T, into type: String.Type) throws -> String {
let data = try self.encode(value, into: Data.self)
let encoding = self._configuration.writerConfiguration.encoding ?? .utf8
return String(data: data, encoding: encoding)!
Expand All @@ -58,7 +58,7 @@ extension CSVEncoder {
/// - parameter value: The value to encode as CSV.
/// - parameter fileURL: The file receiving the encoded values.
/// - parameter append: In case an existing file is under the given URL, this Boolean indicates that the information will be appended to the file (`true`), or the file will be overwritten (`false`).
open func encode<T:Encodable>(_ value: T, into fileURL: URL, append: Bool = false) throws {
public func encode<T:Encodable>(_ value: T, into fileURL: URL, append: Bool = false) throws {
let writer = try CSVWriter(fileURL: fileURL, append: append, configuration: self._configuration.writerConfiguration)
try withExtendedLifetime(try ShadowEncoder.Sink(writer: writer, configuration: self._configuration, userInfo: self.userInfo)) {
try value.encode(to: ShadowEncoder(sink: .passUnretained($0), codingPath: []))
Expand All @@ -71,7 +71,7 @@ extension CSVEncoder {
/// Returns an instance to encode row-by-row the feeded values.
/// - parameter type: The Swift type for a data blob.
/// - returns: Instance used for _on demand_ encoding.
open func lazy(into type: Data.Type) throws -> Lazy<Data> {
public func lazy(into type: Data.Type) throws -> Lazy<Data> {
let writer = try CSVWriter(configuration: self._configuration.writerConfiguration)
let sink = try ShadowEncoder.Sink(writer: writer, configuration: self._configuration, userInfo: self.userInfo)
return Lazy<Data>(sink: sink)
Expand All @@ -80,7 +80,7 @@ extension CSVEncoder {
/// Returns an instance to encode row-by-row the feeded values.
/// - parameter type: The Swift type for a data blob.
/// - returns: Instance used for _on demand_ encoding.
open func lazy(into type: String.Type) throws -> Lazy<String> {
public func lazy(into type: String.Type) throws -> Lazy<String> {
let writer = try CSVWriter(configuration: self._configuration.writerConfiguration)
let sink = try ShadowEncoder.Sink(writer: writer, configuration: self._configuration, userInfo: self.userInfo)
return Lazy<String>(sink: sink)
Expand All @@ -90,7 +90,7 @@ extension CSVEncoder {
/// - parameter fileURL: The file receiving the encoded values.
/// - parameter append: In case an existing file is under the given URL, this Boolean indicates that the information will be appended to the file (`true`), or the file will be overwritten (`false`).
/// - returns: Instance used for _on demand_ encoding.
open func lazy(into fileURL: URL, append: Bool = false) throws -> Lazy<URL> {
public func lazy(into fileURL: URL, append: Bool = false) throws -> Lazy<URL> {
let writer = try CSVWriter(fileURL: fileURL, append: append, configuration: self._configuration.writerConfiguration)
let sink = try ShadowEncoder.Sink(writer: writer, configuration: self._configuration, userInfo: self.userInfo)
return Lazy<URL>(sink: sink)
Expand Down
2 changes: 2 additions & 0 deletions sources/imperative/writer/WriterConfiguration.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Foundation

extension CSVWriter {
/// Configuration for how to write CSV data.
public struct Configuration {
Expand Down