StatefulEncoder

public protocol StatefulEncoder : StatefulCoder

An object that flattens values into a serialized Encoding, maintaining state across the serialization of individual parts.

Note

this protocol matches Foundation’s XXXEncoder types, which—confusingly—do not themselves conform to the Encoder protocol.
  • Returns a serialized representation of subject.

    Declaration

    Swift

    func encode<T>(_ subject: T) throws -> Encoding where T : Encodable
  • encode(_:startState:) Extension method

    Returns a serialized representation of subject, using startState as the initial encoding state.

    Declaration

    Swift

    public mutating func encode<T, State: Sendable>(_ value: T, startState: State) throws -> Encoding
    where T: Encodable