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;
}
}
- Registered by shove
- 0.0.2 released 6 years ago
- shove70/buffer
- MIT License
- Copyright © 2017, Shove
- Authors:
- 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 - Download Stats:
-
-
0 downloads today
-
2 downloads this week
-
2 downloads this month
-
8297 downloads total
-
- Score:
- 2.0
- Short URL:
- buffer.dub.pm