DataStreamSerializer
public protocol DataStreamSerializer : Sendable
A type which can serialize incoming Data
.
-
Type produced from the serialized
Data
.Declaration
Swift
associatedtype SerializedObject : Sendable
-
Serializes incoming
Data
into aSerializedObject
value.Throws
Any error produced during serialization.
Declaration
Swift
func serialize(_ data: Data) throws -> SerializedObject
Parameters
data
Data
to be serialized.
-
decodable(of:
Extension methoddecoder: dataPreprocessor: ) Creates a
DecodableStreamSerializer
instance with the providedDataDecoder
andDataPreprocessor
.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 incomingData
.JSONDecoder()
by default.dataPreprocessor
DataPreprocessor
used to process incomingData
before it’s passed through thedecoder
.PassthroughPreprocessor()
by default.
-
passthrough
Extension methodProvides a
PassthroughStreamSerializer
instance.Declaration
Swift
public static var passthrough: PassthroughStreamSerializer { get }
-
string
Extension methodProvides a
StringStreamSerializer
instance.Declaration
Swift
public static var string: StringStreamSerializer { get }