readJSONDecodable(_:decoder:length:)

Reads length bytes from this ByteBuffer and then attempts to decode them using the JSONDecoder decoder.

Codable+ByteBuffer.swift:48
mutating func readJSONDecodable<T>(_ type: T.Type, decoder: JSONDecoder = JSONDecoder(), length: Int) throws -> T? where T : Decodable

Parameters

type

The type type that is attempted to be decoded.

decoder

The JSONDecoder that is used for the decoding.

length

The number of bytes to decode.

Returns

The decoded value is successful or nil if there are not enough readable bytes available.