Skip to content

Commit

Permalink
Add resultsBuilders
Browse files Browse the repository at this point in the history
  • Loading branch information
tzopiz committed Jul 8, 2024
1 parent 08f1cb3 commit 54c3360
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/FileCache/CSVParsing/CSVParsable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ public protocol CSVParsable {
var csv: String { get }
static func parse(csv: String) -> Self?
}

extension CSVParsable {
static func buildCSV(@CSVBuilder build: () -> String) -> String { build() }
}
2 changes: 2 additions & 0 deletions Sources/FileCache/JSONParsing/JSONParsable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public protocol JSONParsable {
}

public extension JSONParsable {
static func buildJSON(@JSONBuilder build: () -> JSONDictionary) -> JSONDictionary { build() }

var jsonString: String? {
guard let jsonData = try? JSONSerialization.data(withJSONObject: json) else {
DDLogError("Failed to serialize JSON data for \(self)")
Expand Down

0 comments on commit 54c3360

Please sign in to comment.