pbconv

Last updated:

0 purchases

pbconv Image
pbconv Images
Add to Cart

Description:

pbconv

A implement of Dart converter for Protobuf.
Introduction #
Convert a message object to proto buffer binary bytes, Or convert proto buffer binary bytes to a message object.
Examples #
This is the encoder example.
import "dart:io";
import 'package:pbconv/pbconv.dart';

final List<Field> fields = [
RequiredField(1, 'ID', Type.uint32),
RequiredField(2, "Name", Type.string),
OptionalField(3, "Email", Type.string, '[email protected]')
];

main() {
var message = EncoderMessage(fields);
message[fields[0]] = 1;
message[fields[1]] = 'Tom';
var proto = protobufEncode(message);
print(proto.bytes);
File file = File("example.bin");
file.writeAsBytesSync(proto.bytes);
}
copied to clipboard
This is decoder example.
import "dart:io";
import 'dart:typed_data';
import 'package:pbconv/pbconv.dart';

final List<Field> fields = [
RequiredField(1, 'ID', Type.uint32),
RequiredField(2, "Name", Type.string),
OptionalField(3, "Email", Type.string, '[email protected]')
];

main() {
File file = File("example.bin");
var bytes = file.readAsBytesSync();
print(bytes);
var message = protobufDecode(ProtoBytes(fields, bytes as Uint8List));
print(message.toString());
}
copied to clipboard
Features and bugs #
Please file feature requests and bugs at the issue tracker.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.