docs/Protocols/DataStreamSerializer.html
public protocol DataStreamSerializer : Sendable
A type which can serialize incoming Data.
`
SerializedObject
`
Type produced from the serialized Data.
Swift
associatedtype SerializedObject : Sendable
`
serialize(_:)
`
Serializes incoming Data into a SerializedObject value.
Throws
Any error produced during serialization.
Swift
func serialize(_ data: Data) throws -> SerializedObject
| data |
Data to be serialized.
|
`
decodable(of:decoder:dataPreprocessor:)
` Extension method
Creates a DecodableStreamSerializer instance with the provided DataDecoder and DataPreprocessor.
Swift
public static func decodable<T: Decodable>(of type: T.Type,
decoder: any DataDecoder = JSONDecoder(),
dataPreprocessor: any DataPreprocessor = PassthroughPreprocessor()) -> Self where Self == DecodableStreamSerializer<T>
| 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.
|
Self == PassthroughStreamSerializer`
passthrough
` Extension method
Provides a PassthroughStreamSerializer instance.
Swift
public static var passthrough: PassthroughStreamSerializer { get }
Self == StringStreamSerializer`
string
` Extension method
Provides a StringStreamSerializer instance.
Swift
public static var string: StringStreamSerializer { get }