google / google/protobuf.dart

Codec generator?

Open
#149 0 comments 0 reactions 0 assignees View on GitHub
feature request
Dominant language
Dart
Stars
572
Forks
196
Avg merge
1h 59m
Merged PRs (30d)
2

Description

I think it would be worth to create JSON-Codec and Buffer-Codec for the generated messages, as it would reduce some of the boilerplate in the client's code. Maybe as an option in the generated output? A simple example is the following, the extension could be passed in too:

```
class _Message__BufferEncoder extends Converter> {
List convert(Message input) =>
input.writeToBuffer();
}

class _Message__BufferDecoder extends Converter, Message> {
Message convert(List input) =>
new Message.fromBuffer(input);
}

class Message__BufferCodec extends Codec> {
Converter _decoder = new _Message__BufferDecoder();
Converter _encoder = new _Message__BufferEncoder();
Converter, Message> get decoder => _decoder;
Converter> get encoder => _encoder;
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.