Type Alias

CodableWithConfiguration

A type that can convert itself into and out of an external representation with the help of a configuration that handles encoding contained types.

Declaration 宣言

typealias CodableWithConfiguration = DecodableWithConfiguration & EncodableWithConfiguration

Discussion 議論

CodableWithConfiguration is a type alias for the EncodableWithConfiguration and DecodableWithConfiguration protocols. CodableWithConfigurationは、EncodableWithConfigurationDecodableWithConfigurationプロトコルに対する型エイリアスです。 Use this protocol to support codability in a type that can’t conform to Codable by itself, but can do so with additional statically-defined configuration provided by a CodableConfiguration instance.

AttributedString uses this approach to allow an instance to contain arbitrary attributes, including frameworks outside of Foundation or the platform SDK. It does this by including one or more AttributeScope instances, a type that conforms to EncodingConfigurationProviding and DecodingConfigurationProviding. An attribute scope like AttributeScopes.SwiftUIAttributes defines attribute keys, and conforms to AttributeScope to provide configuration instances that know the AttributedStringKey types and their associated Value types. With this type information, an AttributedString can encode all of its attributes, even from frameworks other than Foundation.

See Also 参照

Serializing Arbitrary Payloads 恣意的なペイロードをシリアル化する