puroro, a protocol buffer implementation for Rust

A yet another protocol buffer compiler implementation for Rust language. This project is licensed under Apache 2.0 license.

This is not an officially supported Google product.

See puroro/src/lib.rs for more documents.

important notes

This library is under development and it is very possible to make breaking changes.

Currently this library only supports Rust nightly channel.

How to compile your .pb files to .rs files

First, let's create a crate for your .proto files (and the generated .rs files). Actually it is not required to create a separated crate for the proto files, though I recommend to make it to avoid any unexpected problems.

```shell $ cargo new my-examples --lib $ cd my-examples

Create your .proto files under this directory

$ mkdir protos

Edit your .proto files

$ emacs-vim-nano-or-whatever ./protos/yourproto.proto ```

As an example, let's make a simple proto file test1.proto:

protobuf syntax = "proto3"; package library; message Book { string title = 1; uint32 num_pages = 2; }

Note that the file names does not make any effect in the generated codes. Only the package name (in this case, package library;) makes the effect to the generated code's module name (or file name).

Then edit the Cargo.toml to add the dependency to puroro library crates:

```toml [dependencies] puroro = "*"

[build-dependencies] puroro-plugin = "*" ```

As a last step, create a file build.rs under the crate root directory. Check our sample build.rs and just copy and paste.

Once you have finished these steps, the directory should be like this:

+ my-examples/
    ├ src/
    │   └ (empty)
    ├ protos/
    │   └ test1.proto
    ├ cargo.toml
    ├ build.rs
    ├ (some other generated files)

Then run cargo build command. If it successfully runs, then the generated .rs files will be generated under src/ directory and you can use it from your own crate. Congraturations!

subcrates

TODOs