About PROTOBUF
Google Protocol Buffer (abbreviated PROTOBUF) is a lightweight and efficient structured data storage format, platform-Independent, language-independent, extensible, and can be used in communication protocols and data storage and other fields.
Learning materials: Developer Guide rust used in protobuf
The following take Ubuntu-16.04lts as an example: first, install PROTOC pre-installed
sudo apt-get install autoconf automake libtool Curl make g++ Unzip
Get source code, generate configure
git clone https://github.com/google/protobuf.git
cd protobuf
git submodule update--init--recursive
./ autogen.sh
Compiling the installation
./configure #By Default, the package is installed to/usr/local make
to
check
sudo make Install
sudo Ldconfig # Refresh shared library cache.
Installation steps can refer to: https://github.com/google/protobuf/blob/master/src/README.md Two, install Protoc-gen-rust plug-in
Using Cargo Installation:
Cargo install Protobuf--vers 1.4.4 #1.4.4 is a version number, optionally filled. Install by default to the ~/.cargo/bin directory
can also use the source code installation, from the GitHub clone source code, compile installation, add environment variables.
Installation steps can refer to: Https://github.com/stepancheg/rust-protobuf/tree/master/protobuf-codegen three, write proto file generation corresponding rust file
For illustration (generate Foo.proto corresponding rust file in current directory):
Four, the application of engineering in the Rust Project Cargo.toml added Protobuf
[Dependencies]
Protobuf = "1.4"
To add a reference to the crate:
extern crate Protobuf;
Referencing related APIs ... Other usage Scenarios
"Protocol buffers are not designed to handle large.". Protobuf is highly efficient for message below 1M, but when message is larger than 1M data, protobuf performance is not very good, should be noted when used.
Reference Documentation:
Protocol Buffers-google ' s Data Interchange Format
Rust Use Protobuf
Serialization and deserialization