Hello, all-

I'd like to present a library that I've been working on on-and-off for
the last couple of months.

Protocol Buffers are a format produced by Google that acts as an
Interface Description Language for serializable data. Basically, given a
file containing lines like:

message Point {
        optional int32 x = 1 [default=166];
        required int32 y = 2;
        optional string label = 3;
        message Coord {
                required int32 a = 1;
                required int32 b = 2;

You can get a structure that behaves as:

struct Point {
        int x=166;
        int y;
        string label;
        struct Coord {
                int a,b;

What's the benefit? This structure also has some useful methods for
serialization and deserialization to a well-documented format - in
dproto's case, the resulting data can be stored in any ubyte[].

What makes this library special? Unlike the C++/Java/Python compilers
for .proto files, this library does the conversion at compile time using
mixins and string manipulation. All that's needed is to add the file
directories to the string imports, and then:

        mixin ProtocolBuffer!"point.proto";

Where can you get it?
It's available as a Dub package ("dproto"), or on Github at

dproto is licensed under the BSD 3-clause license, and I'm definitely
open to suggestions for improvement - currently, a lot of the code was
translated from Java and so there are some things that are quite

-Matt Soucy

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to