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
Datainto aSerializedObjectvalue.Throws
Any error produced during serialization.
Declaration
Swift
func serialize(_ data: Data) throws -> SerializedObjectParameters
dataDatato be serialized.
-
decodable(of:Extension methoddecoder: dataPreprocessor: ) Creates a
DecodableStreamSerializerinstance with the providedDataDecoderandDataPreprocessor.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
typeDecodabletype to decode from stream data.decoderDataDecoderused to decode incomingData.JSONDecoder()by default.dataPreprocessorDataPreprocessorused to process incomingDatabefore it’s passed through thedecoder.PassthroughPreprocessor()by default.
-
passthroughExtension methodProvides a
PassthroughStreamSerializerinstance.Declaration
Swift
public static var passthrough: PassthroughStreamSerializer { get }
-
stringExtension methodProvides a
StringStreamSerializerinstance.Declaration
Swift
public static var string: StringStreamSerializer { get }
View on GitHub
Install in Dash