Cerealed v0.6.1: even less boilerplate for binary serialization

via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Mon Aug 3 04:43:12 PDT 2015


On Monday, 3 August 2015 at 09:21:50 UTC, Atila Neves wrote:
> 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

1. Are there any convenience functions similar to msgpack's 
pack() and unpack() providing compactness and elegance as

     import msgpack;
     auto x  = [1,2];
     assert(x.pack.unpack!typeof(x) == x);

2. How does the Cereal performance compare to Msgpack after the 
recent optimizations?


More information about the Digitalmars-d-announce mailing list