Skip to content

map(keyDecoder_valueDecoder_)

MarcoDotIO edited this page Apr 25, 2023 · 1 revision

map(keyDecoder:valueDecoder:)

Deserialize a dictionary of key-value pairs from the Deserializer's input data buffer.

public func map<K, V>(keyDecoder: (Deserializer) throws -> K, valueDecoder: (Deserializer) throws -> V) throws -> [K: V] 

This function first reads the length of the dictionary as a ULEB128-encoded integer. Then, it iteratively decodes keys and values using the provided keyDecoder and valueDecoder closures until the desired number of pairs is deserialized.

Parameters

  • keyDecoder: A closure that takes a Deserializer instance and returns a decoded key of type K.
  • valueDecoder: A closure that takes a Deserializer instance and returns a decoded value of type V.

Throws

Any error that may occur during the deserialization process, such as reading the ULEB128-encoded length, keys, or values.

Returns

A dictionary of [K:​ V] deserialized from the input data buffer.

Types
Protocols
Global Variables
Global Functions
Extensions
Clone this wiki locally