Cerealed v0.6.1: even less boilerplate for binary serialization

Atila Neves via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Mon Aug 3 02:21:48 PDT 2015


http://code.dlang.org/packages/cerealed

What's new?

* Performance improvements
* New UDAs for networking packets for even less required 
boilerplate

The first new thing is self-explanatory. The second one is 
explained briefly in this blog post:

https://www.reddit.com/r/programming/comments/3flnlt/cerealed_a_d_library_for_declarative_binary/

(also on HN but you know how that goes)

The summary is you can now write this:

     struct UdpPacket {
         static struct Header {
             ushort srcPort;
             ushort dstPort;
             ushort length;
             ushort checksum;
         }

         enum headerSize = unalignedSizeof!Header;
         alias header this;

         Header header;
         @LengthInBytes("length - headerSize") ubyte[] data;
     }

Code? Who needs code when the compiler can write it for you?

Atila


More information about the Digitalmars-d-announce mailing list