buffer 0.0.2

A protocol buffer library


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:

A simple and practical protocol buffer library.

Quick Start:

import std.stdio;

import buffer.message;

mixin (LoadBufferFile!"message.buffer");

mixin (LoadBufferScript!`
	message(3) Sample {
		string	name;
		int32	age;
		int16	sex;
	}
`);

// Simple:
void main()
{
	Sample sample = new Sample();
	sample.name = "Tom";
	sample.age = 20;
	sample.sex = 1;
	ubyte[] buf = sample.serialize();
	writeln(buf);
	
	Sample sam = Message.deserialize!Sample(buf);
	writeln("msgid:\t", sam.messageId);
	writeln("name:\t", sam.name);
	writeln("age:\t", sam.age);
	writeln("sex:\t", sam.sex);
}

// Advanced:
void main()
{
	// Set magic number, encryption method and key.
	Message.settings(1229, CryptType.XTEA, "1234");

	Sample sample = new Sample();
	sample.name = "Tom";
	sample.age = 20;
	sample.sex = 1;
	ubyte[] buf = sample.serialize();
	writeln(buf);
	
	TypeInfo_Class typeinfo = Message.getMessageTypeInfo(buf);
	
	switch (typeinfo.name)
	{
		case "app.Sample":
			Sample sam = Message.deserialize!Sample(buf);
			writeln("msgid:\t", sam.messageId);
			writeln("name:\t", sam.name);
			writeln("age:\t", sam.age);
			writeln("sex:\t", sam.sex);
			break;
		case "...":
			break;
		default:
			break;
	}
}

Authors:
  • Shove
Dependencies:
cryption
Versions:
0.2.41 2022-Jan-25
0.2.40 2021-Jun-09
0.2.39 2020-Dec-03
0.2.38 2020-Oct-14
0.2.37 2020-Sep-01
Show all 74 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 8301 downloads total

Score:
2.0
Short URL:
buffer.dub.pm