protocol
KeyedEncodingContainerProtocol
Inheritance | View Protocol Hierarchy → |
---|---|
Associated Types |
|
Import |
|
Instance Variables
The path of coding keys taken to get to this point in encoding.
Declaration
var
codingPath
: [
CodingKey
] {
get
}
Instance Methods
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
(
_
value
:
Bool
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
(
_
value
:
Double
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
(
_
value
:
Float
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
(
_
value
:
Int
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
(
_
value
:
Int8
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
(
_
value
:
Int16
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
(
_
value
:
Int32
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
(
_
value
:
Int64
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
(
_
value
:
String
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
(
_
value
:
UInt
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
(
_
value
:
UInt8
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
(
_
value
:
UInt16
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
(
_
value
:
UInt32
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
(
_
value
:
UInt64
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encode
<
T
>
(
_
value
:
T
,
forKey
key
:
Self
.
Key
)
throws
Encodes a reference to the given object only if it is encoded unconditionally elsewhere in the payload (previously, or in the future).
For encoders which don't support this feature, the default implementation encodes the given object unconditionally.
object
: The object to encode.
key
: The key to associate the object with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeConditional
<
T
>
(
_
object
:
T
,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Bool
?,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Double
?,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Float
?,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Int
?,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Int8
?,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Int16
?,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Int32
?,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Int64
?,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
(
_
value
:
String
?,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
(
_
value
:
UInt
?,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
(
_
value
:
UInt8
?,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
(
_
value
:
UInt16
?,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
(
_
value
:
UInt32
?,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
(
_
value
:
UInt64
?,
forKey
key
:
Self
.
Key
)
throws
Encodes the given value for the given key if it is not nil
.
value
: The value to encode.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if the given value is invalid in
the current context for this format.
Declaration
mutating
func
encodeIfPresent
<
T
>
(
_
value
:
T
?,
forKey
key
:
Self
.
Key
)
throws
Encodes a null value for the given key.
key
: The key to associate the value with.
throws: EncodingError.invalidValue
if a null value is invalid in the
current context for this format.
Declaration
mutating
func
encodeNil
(
forKey
key
:
Self
.
Key
)
throws
Stores a keyed encoding container for the given key and returns it.
keyType
: The key type to use for the container.
key
: The key to encode the container for.
returns: A new keyed encoding container.
Declaration
mutating
func
nestedContainer
<
NestedKey
>
(
keyedBy
keyType
:
NestedKey
.
Type
,
forKey
key
:
Self
.
Key
) -
>
KeyedEncodingContainer
<
NestedKey
>
where
NestedKey
:
CodingKey
Stores an unkeyed encoding container for the given key and returns it.
key
: The key to encode the container for.
returns: A new unkeyed encoding container.
Declaration
mutating
func
nestedUnkeyedContainer
(
forKey
key
:
Self
.
Key
) -
>
UnkeyedEncodingContainer
Stores a new nested container for the default super
key and returns A
new encoder instance for encoding super
into that container.
Equivalent to calling superEncoder(forKey:)
with
Key(stringValue: "super", intValue: 0)
.
returns: A new encoder to pass to super.encode(to:)
.
Declaration
mutating
func
superEncoder
() -
>
Encoder
Stores a new nested container for the given key and returns A new encoder
instance for encoding super
into that container.
key
: The key to encode super
for.
returns: A new encoder to pass to super.encode(to:)
.
Declaration
mutating
func
superEncoder
(
forKey
key
:
Self
.
Key
) -
>
Encoder
Default Implementations
Declaration
mutating
func
encodeConditional
<
T
>
(
_
object
:
T
,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Bool
?,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Double
?,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Float
?,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Int
?,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Int8
?,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Int16
?,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Int32
?,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
(
_
value
:
Int64
?,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
(
_
value
:
String
?,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
(
_
value
:
UInt
?,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
(
_
value
:
UInt8
?,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
(
_
value
:
UInt16
?,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
(
_
value
:
UInt32
?,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
(
_
value
:
UInt64
?,
forKey
key
:
Self
.
Key
)
throws
Declaration
mutating
func
encodeIfPresent
<
T
>
(
_
value
:
T
?,
forKey
key
:
Self
.
Key
)
throws
A type that provides a view into an encoder's storage and is used to hold the encoded properties of an encodable type in a keyed manner.
Encoders should provide types conforming to
KeyedEncodingContainerProtocol
for their format.