Swiftpack.co - AlanQuatermain/swift-nio-protobuf as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by AlanQuatermain.
AlanQuatermain/swift-nio-protobuf v0.1.2
Codecs to aid in handling protocol buffers in your swift-nio pipeline.
⭐️ 4
🕓 5 years ago
.package(url: "https://github.com/AlanQuatermain/swift-nio-protobuf.git", from: "v0.1.2")

NIOProtobuf

This library contains some useful tools for anyone using Protobuf encoded messages in their swift-nio stack. If not for the dependency on SwiftProtobuf and thus Foundation, this would likely just be a pull request for swift-nio-extras. As it is, I'm happy to keep it here.

The functionality here was inspired by the protobuf codecs in Netty.

Using NIOProtobuf

dependencies: [
    .package(url: "https://github.com/AlanQuatermain/swift-nio-protobuf.git", .upToNextMinor(from: "0.1.0")),
],

Contents

  • VarintFrameDecoder and VarintLengthFieldPrepender: Implements VarInt64-based length encoding of messages from up/down the stack. Anything passed to the prepender will be prepended with its length, varint-encoded. The decoder will read varints and accumulate the appropriate number of bytes from its own input, passing each slice to the next handler once all bytes have arrived.
  • ProtobufDecoder and ProtobufEncoder: An encoder/decoder pair that encoder or decode a protobuf message type specified as a generic parameter. Note that both will send all input bytes into the SwiftProtobuf encoder/decoder. It is anticipated that you'll want to chain these together to parse or generate standard varint32-delimited protobuf streams.

GitHub

link
Stars: 4
Last commit: 5 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics