Skip to content

Commit

Permalink
Add options arg for custom coding
Browse files Browse the repository at this point in the history
  • Loading branch information
sidepelican committed Jan 17, 2024
1 parent 78f6abc commit 71abcd8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Sources/D1Kit/D1Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import HTTPTypes

public struct D1Client: Sendable {
public init(httpClient: HTTPClientProtocol, accountID: String, apiToken: String) {
public init(httpClient: any HTTPClientProtocol, accountID: String, apiToken: String) {
precondition(accountID.isASCII)
precondition(apiToken.isASCII)
self.httpClient = httpClient
Expand Down
2 changes: 1 addition & 1 deletion Sources/D1Kit/D1ParameterBindable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extension Date: D1ParameterBindable {
case .formatted(let formatter):
return formatter.string(from: self)
case .custom(let custom):
return custom(self)
return custom(self, options)
}
}
}
4 changes: 2 additions & 2 deletions Sources/D1Kit/D1ParameterEncodingOptions.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

public protocol D1ParameterEncodingOptionKey {
associatedtype Value
associatedtype Value: Sendable
static var defaultValue: Self.Value { get }
}

Expand Down Expand Up @@ -30,7 +30,7 @@ public enum D1DateEncodingStrategy {
case millisecondsSince1970
case iso8601
case formatted(DateFormatter)
@preconcurrency case custom(@Sendable (Date) -> String)
@preconcurrency case custom(@Sendable (Date, D1ParameterEncodingOptions) -> String)
}

public struct D1DateEncodingStrategyKey: D1ParameterEncodingOptionKey {
Expand Down

0 comments on commit 71abcd8

Please sign in to comment.