StatefulCoder
public protocol StatefulCoder
An object that flattens values into—or reconstitutes values from—a serialized Encoding,
maintaining state across the (de)serialization of individual parts.
Note
this protocol matches Foundation’sXXXEncoder/XXXDecoder types,
which—confusingly—do not themselves conform to the Encoder/Decoder protocols.
-
The complete result of serializing anything with
self.Declaration
Swift
associatedtype Encoding = Data -
The storage vehicle for state.
Declaration
Swift
var userInfo: [CodingUserInfoKey : any Sendable] { get set } -
setState(_:Extension method) Injects initialState into
selffor use as mutable storage during encoding/decoding.Declaration
Swift
public mutating func setState<T>(_ initialState: T) where T : Sendable
View on GitHub