forked from vapor/postgres-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPostgreSQLData.swift
35 lines (28 loc) · 945 Bytes
/
PostgreSQLData.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import Foundation
/// Supported `PostgreSQLData` data types.
public struct PostgreSQLData {
/// The data's type.
public var type: PostgreSQLDataType
/// The data's format.
public var format: PostgreSQLFormatCode
/// The actual data.
public var data: Data?
public init(type: PostgreSQLDataType, format: PostgreSQLFormatCode = .binary, data: Data? = nil) {
self.type = type
self.format = format
self.data = data
}
}
extension PostgreSQLData: CustomStringConvertible {
/// See `CustomStringConvertible.description`
public var description: String {
return "\(type) (\(format)) \(data?.hexDebug ?? "nil")"
}
}
/// MARK: Equatable
extension PostgreSQLData: Equatable {
/// See Equatable.==
public static func ==(lhs: PostgreSQLData, rhs: PostgreSQLData) -> Bool {
return lhs.format == rhs.format && lhs.type == rhs.type && lhs.data == rhs.data
}
}