aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorOskari Timperi <oskari.timperi@iki.fi>2018-03-26 21:07:42 +0300
committerOskari Timperi <oskari.timperi@iki.fi>2018-03-26 21:07:42 +0300
commite63837a7f2ff32c718b272fe06a69506b411584a (patch)
treed74f715c70b1dd4cba647a12a4007ba84c7ba52e /README.md
parente66e2b653e012a2810ccde9a630358528999b6ce (diff)
downloadnimpb-e63837a7f2ff32c718b272fe06a69506b411584a.tar.gz
nimpb-e63837a7f2ff32c718b272fe06a69506b411584a.zip
Add README
Diffstat (limited to 'README.md')
-rw-r--r--README.md48
1 files changed, 48 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..14dd3ab
--- /dev/null
+++ b/README.md
@@ -0,0 +1,48 @@
+# Protocol Buffers for Nim
+
+A pure Nim library for dealing with protobuf serialization and deserialization. A `protoc` plugin is also included which can be used for generating Nim code, usable by the library, from `.proto` files.
+
+At the moment this is at a very rough state. Do not use for any kind of production use.
+
+# Example
+
+Given the following file:
+
+```
+syntax = "proto3";
+
+message Test1 {
+ int32 a = 1;
+}
+```
+
+The `protoc` plugin will basically generate the following code:
+
+```nim
+const
+ Test1Desc = MessageDesc(
+ name: "Test1",
+ fields: @[
+ FieldDesc(
+ name: "a",
+ number: 1,
+ ftype: FieldType.Int32,
+ label: FieldLabel.Optional,
+ typeName: "",
+ packed: false
+ )
+ ]
+ )
+
+generateMessageType(Test1Desc)
+generateMessageProcs(Test1Desc)
+```
+
+And you can use it like this:
+
+```
+let message = newTest1()
+setA(message, 150)
+let pbso = newProtobufStream(newFileStream(stdout))
+writeTest1(pbso, message)
+```