PackStream is a binary message format very similar to MessagePack. It can be used stand-alone, but it has been built as a message format for use in the Bolt protocol to communicate between the Neo4j server and its clients.
This implementation is written in Swift, primarily as a dependency for the Swift Bolt implementation. That implementation will in turn provide Theo, the Neo4j Swift driver, with Bolt support.
Usage
Through PackStream you can encode Bool, Int, Float (Double in Swift lingo), String, List, Map and Structure. They all implement the PackProtocol, so if you want to have a collection of packable items, you can specify them as implementing PackProtocol.
Example
First, remember to
import PackStream
Then you can use it, like for instance so:
let map = Map(dictionary: [
"alpha": 42,
"beta": 39.3,
"gamma": "☺",
"delta": List(items: [1,2,3,4])
])
let result = try map.pack()
let restored = try Map.unpack(result)
A list of the numbers 1 to 40
let items = Array(Int8(1)...Int8(40))
let value = List(items: items)
PackStream implementation in Swift
PackStream is a binary message format very similar to MessagePack. It can be used stand-alone, but it has been built as a message format for use in the Bolt protocol to communicate between the Neo4j server and its clients.
This implementation is written in Swift, primarily as a dependency for the Swift Bolt implementation. That implementation will in turn provide Theo, the Neo4j Swift driver, with Bolt support.
Usage
Through PackStream you can encode Bool, Int, Float (Double in Swift lingo), String, List, Map and Structure. They all implement the
PackProtocol
, so if you want to have a collection of packable items, you can specify them as implementing PackProtocol.Example
First, remember to
Then you can use it, like for instance so:
A list of the numbers 1 to 40
gets encoded to the following bytes
Getting started
To use directly with Xcode, type “swift package generate-xcodeproj”
Swift Package Manager
Add the following to your dependencies array in Package.swift:
and you can now do a
CocoaPods
Add the
to your Podfile, and you can now do
to have PackStream included in your Xcode project via CocoaPods
Carthage
Put
in your Cartfile. If this is your entire Cartfile, do
If you have already done that, do
instead.
Then do
And Carthage is now set up. You can now do
and you should find a build for macOS, iOS, tvOS and watchOS in Carthage/Build
Protocol documentation
For reference, please see driver.py in Boltkit