Structures

The following structures are available globally.

  • Declaration

    Swift

    public struct CodingStorageError : Error
  • References an element in any keyed container meta. This meta may be in the storage of another container or directly on the stack.

    See more

    Declaration

    Swift

    public struct KeyedContainerElementReference : ContainerElementReference
  • References an element in any unkeyed container meta. This meta may be in the storage of another container or directly on the stack.

    See more

    Declaration

    Swift

    public struct UnkeyedContainerElementReference : ContainerElementReference
  • 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.

    See more

    Declaration

    Swift

    public struct KeyedErrorContainer<K> : Encoder, KeyedEncodingContainerProtocol, UnkeyedEncodingContainer, SingleValueEncodingContainer where K : CodingKey
  • A implementation of MetaSupplier and Unwrapper that gets Metas out of your way, so you will only have to work with Arrays, Dictionarys and the Primitive types you pass to it.

    See more

    Declaration

    Swift

    public struct PrimitivesEnumTranslator : MetaSupplier, Unwrapper
  • Represents a nil value independant of the Optionals generic Wrapped parameter.

    See more

    Declaration

    Swift

    public struct NilMarker : DirectlyCodable
    extension NilMarker: NilMeta
  • This MetaSupplier and Unwrapper implementation provides an easy way to use MetaSerialization.

    To use it, define a marker protocol and extend your primitive types (the types you can represent directly in your end format, e.g. String, Int, etc…) to conform to it:

    protocol Primitive: Meta {}
    extension String: Primitive {}
    extension Int: Primitive {}
    ...
    

    If you wan’t to allow nil values, extend NilMarker to conform to your marker protocol.

    Now create a PrimitivesProtocolTranslator with your marker protocol as generic Primitive parameter. If you pass this translator to a MetaEncoder, the encoder will create a meta tree that consists only of types conforming to your marker protocol, Array where the elements will also conform to your marker protocol and Dictionary (again conforming to marker) (the string keys aren’t aviodable per se). These arrays and dictionaries may be arbitrarily nested. Note that the arrays (and dictionaries) will be of type Array and not Array but you may safely assume that they conform to your marker protocol.

    The definition of PrimitivesProtocolTranslator does not require Primitive to conform to Meta. However all your types need to conform to meta, otherwise the encoding process will crash at some point. This requirement isn’t implemented in the first place, because otherwise it was not possible to set Primitive to a protocol that simply.

    There is another issue right now: PrimitivesProtocolTranslator needs two Generic parameters because of an inconsistency in swift’s type checking realted to protocols as generic paramters (https://bugs.swift.org/browse/SR-6872?jql=text%20~%20%22type%20check%20with%20protocol%22). If YourMarkerProtocol is your marker protocol the first type parameter should be YourMarkerProtocol and the second type should be YourMarkerProtocol.Type.

    protocol YourMarker: Meta {}
    let translator = PrimitivesProtocolTranslator<YourMarker, YourMarker.Type>()
    

    However, with this you may also specify two diffrent markers for encodign and decoding, since the first type will be used only during encoding and the second only during decoding.

    See more

    Declaration

    Swift

    public struct PrimitivesProtocolTranslator<Primitive, PrimitiveType> : MetaSupplier, Unwrapper
  • A wrapper struct around arbitrary coding keys.

    See more

    Declaration

    Swift

    public struct MetaCodingKey
  • A special coding key represents an index in an unkeyed container

    See more

    Declaration

    Swift

    public struct IndexCodingKey : CodingKey
  • A CodingKey type initalizable with any string or int value.

    This coding key type is exapressible by a string literal in the form <stringValue>,<intValue> where <stringValue> it the keys string value and <intValue> is the keys int value. You may ommit ,<intValue>, in which case the coding key will have no int value. You may also ommit <stringValue> in which case coding keys stringValue will be “(intValue)”.

    Therefor valid string literals for a coding key are:

    • <stringValue>,<intValue>
    • <stringValue>
    • ,<intValue> If the string literal includes more than one , sequence, only the string after the last occurence will be interpreted as int value.

    If isn’t convertible to Int, the coding key will be initalizes with the while string literal as stringValue and without an intValue.

    See more

    Declaration

    Swift

    public struct StandardCodingKey : CodingKey, ExpressibleByStringLiteral, Equatable