DecodableStreamSerializer
public struct DecodableStreamSerializer<T> : DataStreamSerializer where T : Decodable
DataStreamSerializer
which uses the provided DataPreprocessor
and DataDecoder
to serialize the incoming Data
.
-
DataDecoder
used to decode incomingData
.Declaration
Swift
public let decoder: DataDecoder
-
DataPreprocessor
incomingData
is passed through before being passed to theDataDecoder
.Declaration
Swift
public let dataPreprocessor: DataPreprocessor
-
Creates an instance with the provided
DataDecoder
andDataPreprocessor
.Declaration
Swift
public init(decoder: DataDecoder = JSONDecoder(), dataPreprocessor: DataPreprocessor = PassthroughPreprocessor())
Parameters
decoder
DataDecoder
used to decode incomingData
.JSONDecoder()
by default.dataPreprocessor
DataPreprocessor
used to process incomingData
before it’s passed through thedecoder
.PassthroughPreprocessor()
by default. -
Declaration
Swift
public func serialize(_ data: Data) throws -> T