Type Aliases

The following type aliases are available globally.

  • An Encoder that returns an ErrorContainer in all methods.

    Declaration

    Swift

    public typealias ErrorEncoder = ErrorContainer
  • A keyed, unkeyed, single value container and encoder that will throw an error in all methods it can throw and return another KeyedErrorContainer in all other methods.

    Declaration

    Swift

    public typealias ErrorContainer = KeyedErrorContainer<StandardCodingKey>
  • A protocol for any kind of encoded information.

    To use this protocol extend your raw data type to conform to this protocol. Implement provideNewEncoder() and provideNewDecoder(). You may just return a new MetaEncoder/MetaDecoder there. Also implement convert() -> Meta and init(meta: Meta).

    After extending your raw type, use init(encoding: ) to encode and decode(type: ) to decode.

    It is usefull to write a subprotocol of Representation before you extend your raw data type. For example, if you want to write a library for parsing JSON, first write a marker protocol JSON: Representation, for which you provide the default implementation in an extension and then extends your raw type, e.g. Data by JSON. When you encode or decode to or from the raw type you should give the reader and swift a hint what format to use, by adding as JSON to the raw types object. This will save you time if you decide to add another serialization framwork to your application that has the same raw representation type and will give some hints about what you are doing right inside your code.

    Declaration

    Swift

    public typealias Representation = EncodingRepresentation & DecodingRepresentation
  • This protocol provides a blueprint for a serialization class.

    A serialization class is an intermediate, delegating the tasks of encoding and decoding to an Encoder or Decoder, but does so while the user creates a new instance of it and uses this classes methods instead of them of Encodable and Decodable (as he would if you used Representation)

    Declaration

    Swift

    public typealias Serialization = IntermediateEncoder & IntermediateDecoder
  • Declaration

    Swift

    public typealias KeyedContainerMeta = EncodingKeyedContainerMeta & DecodingKeyedContainerMeta
  • implement this protocol if a type is supported directly by the Translator and you won’t have to write any code for coding. For implementation details, see DirectlyDecodable and DirectlyEncodable

    Throws

    The same errors as Decoder.singleValueContainer() and SingleValueContainer.decode()

    Declaration

    Swift

    public typealias DirectlyCodable = DirectlyDecodable & DirectlyEncodable