Back to Alamofire

DecodableStreamSerializer

docs/Structs/DecodableStreamSerializer.html

5.12.01.5 KB
Original Source

DecodableStreamSerializer

public struct DecodableStreamSerializer<T> : DataStreamSerializer where T : Decodable, T : Sendable

DataStreamSerializer which uses the provided DataPreprocessor and DataDecoder to serialize the incoming Data.

`

                decoder
                `

DataDecoder used to decode incoming Data.

Declaration

Swift

public let decoder: any DataDecoder

`

                dataPreprocessor
                `

DataPreprocessor incoming Data is passed through before being passed to the DataDecoder.

Declaration

Swift

public let dataPreprocessor: any DataPreprocessor

`

                init(decoder:dataPreprocessor:)
                `

Creates an instance with the provided DataDecoder and DataPreprocessor.

Declaration

Swift

public init(decoder: any DataDecoder = JSONDecoder(), dataPreprocessor: any DataPreprocessor = PassthroughPreprocessor())

Parameters

| decoder |

DataDecoder used to decode incoming Data. JSONDecoder() by default.

| | dataPreprocessor |

DataPreprocessor used to process incoming Data before it’s passed through the decoder. PassthroughPreprocessor() by default.

|

`

                serialize(_:)
                `

Declaration

Swift

public func serialize(_ data: Data) throws -> T