SLIP is a lightweight package for the SLIP packets, as documented in RFC 1055. It defines encoding and decoding and handles double-ended SLIP encoded packets.
SLIP is available as a Swift Package Manager package. You can add it to your project from Xcode's "Swift Packages" option in the File menu.
.package(url: "https://github.com/mennabah/SLIP.git", from: "1.0.0")
SLIP defines a global, single struct access for the functionality of the package. Start by creating an instance:
let packet = SLIP.Packet(<#T##YourData#>)
Then use that instance to encode the packet.
let encoded = packet.encoded
Or decode it
let decoded = try? packet.decoded
Contrary to the reference implementation described in RFC 1055, which chooses to essentially ignore protocol errors, the decoded
method in the SLIP package use a SLIPError.protocolError
error to indicate protocol errors, i.e. SLIP packets with invalid byte sequences.
You can optionally opt-in to ignore decoding errors by specifying ignoresError
in the Packet(_:ignoresProtocolError:)
initializer.