Back to Alamofire

DataStreamSerializer

docs/docsets/Alamofire.docset/Contents/Resources/Documents/Protocols/DataStreamSerializer.html

5.12.02.3 KB
Original Source

DataStreamSerializer

public protocol DataStreamSerializer : Sendable

A type which can serialize incoming Data.

`

                SerializedObject
                `

Type produced from the serialized Data.

Declaration

Swift

associatedtype SerializedObject : Sendable

`

                serialize(_:)
                `

Serializes incoming Data into a SerializedObject value.

Throws

Any error produced during serialization.

Declaration

Swift

func serialize(_ data: Data) throws -> SerializedObject

Parameters

| data |

Data to be serialized.

|

Serialization

`

                decodable(of:decoder:dataPreprocessor:)
                ` Extension method 

Creates a DecodableStreamSerializer instance with the provided DataDecoder and DataPreprocessor.

Declaration

Swift

public static func decodable<T: Decodable>(of type: T.Type,
                                           decoder: any DataDecoder = JSONDecoder(),
                                           dataPreprocessor: any DataPreprocessor = PassthroughPreprocessor()) -> Self where Self == DecodableStreamSerializer<T>

Parameters

| type |

Decodable type to decode from stream data.

| | 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.

|

Available where Self == PassthroughStreamSerializer

`

                passthrough
                ` Extension method 

Provides a PassthroughStreamSerializer instance.

Declaration

Swift

public static var passthrough: PassthroughStreamSerializer { get }

Available where Self == StringStreamSerializer

`

                string
                ` Extension method 

Provides a StringStreamSerializer instance.

Declaration

Swift

public static var string: StringStreamSerializer { get }