The Swift PacketProcessor provides a simple, type-safe way of handling structured packets given a data stream.
PacketProcessor handles the details of buffer management when reading a data stream. Callers need only push newly received data to the PacketProcessor. The correct handlers for the appropriately typed packet will be called when appropriate.
Packet definitions must include rules for validating the packet and returning the number of data elements consumed by the packet. See DataPacket and StringPacket.
Streams can have a base collection type of String or Data by initializing as PacketProcessor<String> or PacketProcessor<Data>.
Installation
Swift Package Manager
Add the PacketProcessor package to the dependencies within your application’s Package.swift file. Substitute “x.y.z” with the latest PacketProcessor release.
PacketProcessor
The Swift
PacketProcessorprovides a simple, type-safe way of handling structured packets given a data stream.PacketProcessorhandles the details of buffer management when reading a data stream. Callers need only push newly received data to thePacketProcessor. The correct handlers for the appropriately typed packet will be called when appropriate.Packet definitions must include rules for validating the packet and returning the number of data elements consumed by the packet. See
DataPacketandStringPacket.Streams can have a base collection type of
StringorDataby initializing asPacketProcessor<String>orPacketProcessor<Data>.Installation
Swift Package Manager
Add the
PacketProcessorpackage to the dependencies within your application’sPackage.swiftfile. Substitute “x.y.z” with the latest PacketProcessor release.Add
PacketProcessorto your target’s dependencies: