xpacket 0.2.0

Packet encoder and decoder generator


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Create packet encoders and decoders without writing any encode or decode method.

DUB Package codecov Build Status

import xpacket;

class MyPacket : PacketImpl!(Endian.bigEndian, ubyte, varuint) {

	enum ubyte ID = 1;

	uint integer;
	ubyte[] array;
	@LittleEndian short le;

	mixin Make;

}

MyPacket packet = new MyPacket();
packet.integer = 12;
packet.array = [1, 2, 3];
packet.le = 1;

assert(packet.autoEncode() == [

	// `ID` constant encoded as an unsigned byte as specified in the
	// second field of PacketImpl
	1,
	
	// `integer` field encoded as big endian as specified in the first
	// field of PacketImpl
	0, 0, 0, 12,
	
	// `array` field's length encoded as unsigned varint, as specified
	// in the third field of PacketImpl
	3,
	
	// content of `array`, a sequence of 3 bytes
	1, 2, 3,
	
	// content of `le` encoded as little endian because the @LittleEndian
	// attribute overrides the default endianness specified in PacketImpl
	1, 0,
	
]);
Authors:
  • Kripth
Dependencies:
xserial
Versions:
0.2.0 2018-Aug-26
0.1.0 2018-Aug-22
~master 2018-Aug-26
Show all 3 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 0 downloads total

Score:
1.1
Short URL:
xpacket.dub.pm