DecodableStreamSerializer
public struct DecodableStreamSerializer<T> : DataStreamSerializer where T : Decodable, T : Sendable
DataStreamSerializer
which uses the provided DataPreprocessor
and DataDecoder
to serialize the incoming Data
.
-
DataDecoder
used to decode incomingData
.Declaration
Swift
public let decoder: any DataDecoder
-
DataPreprocessor
incomingData
is passed through before being passed to theDataDecoder
.Declaration
Swift
public let dataPreprocessor: any DataPreprocessor
-
Creates an instance with the provided
DataDecoder
andDataPreprocessor
.Declaration
Swift
public init(decoder: any DataDecoder = JSONDecoder(), dataPreprocessor: any 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