Skip to content
Codecs to aid in handling protocol buffers in your swift-nio pipeline.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


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: "", .upToNextMinor(from: "0.1.0")),


  • 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.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.