DataLireCoder swift package

This commit is contained in:
2025-04-27 12:53:43 +03:00
parent 2cca986016
commit 5aec6ea578
60 changed files with 7144 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
import Foundation
protocol Container {
associatedtype Encoder: Swift.Encoder
var encoder: Encoder { get }
}

View File

@@ -0,0 +1,6 @@
import Foundation
public protocol DateEncoder {
func encode(_ date: Date, to encoder: any ValueEncoder) throws
func encode(_ date: Date, for key: any CodingKey, to encoder: any RowEncoder) throws
}

View File

@@ -0,0 +1,8 @@
import Foundation
public protocol Encoder: Swift.Encoder {
associatedtype SQLiteData
var dateEncoder: any DateEncoder { get }
var sqliteData: SQLiteData { get }
}

View File

@@ -0,0 +1,15 @@
import Foundation
protocol Flattenable {
func flattened() -> Any?
}
extension Optional: Flattenable {
func flattened() -> Any? {
switch self {
case .some(let x as Flattenable): x.flattened()
case .some(let x): x
case .none: nil
}
}
}

View File

@@ -0,0 +1,12 @@
import Foundation
import DataLiteCore
public protocol RowEncoder: Encoder {
var count: Int { get }
func set(_ value: Any, for key: CodingKey) throws
func encodeNil(for key: CodingKey) throws
func encodeDate(_ date: Date, for key: CodingKey) throws
func encode<T: SQLiteRawBindable>(_ value: T, for key: CodingKey) throws
func encoder(for key: CodingKey) throws -> any Encoder
}

View File

@@ -0,0 +1,8 @@
import Foundation
import DataLiteCore
public protocol ValueEncoder: Encoder {
func encodeNil() throws
func encodeDate(_ date: Date) throws
func encode<T: SQLiteRawBindable>(_ value: T) throws
}