This crate implements the components required to build a working Thrift server and client. It is divided into the following modules:
- errors
- protocol
- transport
- server
- autogen
The modules are layered as shown. The generated
layer is code generated by the
Thrift compiler's Rust plugin. It uses the components defined in this crate to
serialize and deserialize types and implement RPC. Users interact with these
types and services by writing their own code on top.
+-----------+
| app dev |
+-----------+
| generated | <-> errors/results
+-----------+
| protocol |
+-----------+
| transport |
+-----------+
Add thrift = "x.y.z"
to your Cargo.toml
, where x.y.z
is the version of the
Thrift compiler you're using.
Full Rustdoc
The Rust library and auto-generated code targets Rust versions 1.28+. It does not currently use any Rust 2018 features.
Breaking changes are minimized. When they are made they will be outlined below with transition guidelines.
-
[THRIFT-4529] - Rust enum variants are now camel-cased instead of uppercased to conform to Rust naming conventions
Previously, enum variants were uppercased in the auto-generated code. For example, the following thrift enum:
// THRIFT enum Operation { ADD, SUBTRACT, MULTIPLY, DIVIDE, }
used to generate:
// OLD AUTO-GENERATED RUST pub enum Operation { ADD, SUBTRACT, MULTIPLY, DIVIDE, }
It now generates:
// NEW AUTO-GENERATED RUST pub enum Operation { Add, Subtract, Multiply, Divide, }
You will have to change all enum variants in your code to use camel-cased names. This should be a search and replace.
Bug reports and PRs are always welcome! Please see the Thrift website for more details.
Thrift Rust support requires code in several directories:
compiler/cpp/src/thrift/generate/t_rs_generator.cc
: binding code generatorlib/rs
: runtime librarylib/rs/test
: supplemental teststutorial/rs
: tutorial client and servertest/rs
: cross-language test client and server
All library code, test code and auto-generated code compiles and passes clippy without warnings. All new code must do the same! When making changes ensure that:
rustc
does does output any warningsclippy
with default settings does not output any warnings (includes auto-generated code)cargo test
is successfulmake precross
andmake check
are successfultutorial/bin/tutorial_client
andtutorial/bin/tutorial_server
communicate