struct PredicateCodableConfiguration: CustomDebugStringConvertible, Sendable
<aside> π‘
ν΄λΉ configurationμΌλ‘ CodableWithConfiguration
νλ‘ν μ½ μ€μμ±μ μΆκ°νλ©΄ encoding/decoding μμ
μ predicateμ΄ ν¬ν¨ν μ μλ νμ
λ° keypathλ₯Ό μ νν μ μλ€.
<aside> <img src="/icons/list_blue.svg" alt="/icons/list_blue.svg" width="40px" /> λͺ©μ°¨
</aside>
</aside>
λ€μκ³Ό κ°μ΄ μμ±ν΄λ³Ό μ μλ€:
var configuration = PredicateCodableConfiguration.standardConfiguration
configuration.allowType(Message.self, identifier: "MyApp.Message")
configuration.allowType(Person.self, identifier: "MyApp.Person")
configuration.allowKeyPath(\\Message.sender, identifier: "MyApp.Message.sender")
configuration.allowKeyPath(\\Person.firstName, identifier: "MyApp.Person.firstName")
configuration.allowKeyPath(\\Person.lastName, identifier: "MyApp.Person.lastName")
struct MyRequest: Codable {
let predicate: Predicate<Message>
func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(predicate, forKey: .predicate, configuration: **configuration**)
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
predicate = try container.decode(Predicate<Message>.self, forKey: .predicate, configuration: **configuration**)
}
}
μ μμ μμ predicate
νλ‘νΌν°κ° configuration
μμ νμ©νμ§ μμ νμ
λλ keypathλ₯Ό ν¬ν¨ν κ²½μ°, encoding/decoding μμ
μ μλ¬λ₯Ό λμ§λ€.
init()
static let standardConfiguration: PredicateCodableConfiguration
mutating func allowType(_ type: Any.Type, identifier: String? = nil)
mutating func disallowType(_ type: Any.Type)
mutating func allowPartialType(_ type: Any.Type, identifier: String)
mutating func disallowPartialType(_ type: Any.Type)
mutating func allowKeyPath(_ keyPath: AnyKeyPath, identifier: String)
mutating func disallowKeyPath(_ keyPath: AnyKeyPath)
mutating func allowKeyPathsForPropertiesProvided<T>(by type: T.Type, recursive: Bool = false) where T: PredicateCodableKeyPathProviding
mutating func disallowKeyPathsForPropertiesProvided<T>(by type: T.Type, recursive: Bool = false) where T: PredicateCodableKeyPathProviding
mutating func allow(_ other: PredicateCodableConfiguration)
// conforming CustomDebugStringConvertible protocol
var debugDescription: String