blob: f518f4eb6d82a46039c778679d9abf1cc96b284c [file] [log] [blame] [view]
Allen George8b96bfb2016-11-02 08:01:08 -04001# Rust Thrift library
2
3## Overview
4
5This crate implements the components required to build a working Thrift server
6and client. It is divided into the following modules:
7
8 1. errors
9 2. protocol
10 3. transport
11 4. server
12 5. autogen
13
14The modules are layered as shown. The `generated` layer is code generated by the
15Thrift compiler's Rust plugin. It uses the components defined in this crate to
16serialize and deserialize types and implement RPC. Users interact with these
17types and services by writing their own code on top.
18
19 ```text
20 +-----------+
21 | app dev |
22 +-----------+
23 | generated | <-> errors/results
24 +-----------+
25 | protocol |
26 +-----------+
27 | transport |
28 +-----------+
29 ```
30
31## Using this crate
32
33Add `thrift = "x.y.z"` to your `Cargo.toml`, where `x.y.z` is the version of the
34Thrift compiler you're using.
35
36## API Documentation
37
38Full [Rustdoc](https://docs.rs/thrift/)
39
GREATEST Wiggler EvaR!b57d1262018-11-09 07:54:32 -050040## Compatibility
41
42The Rust library and auto-generated code targets Rust versions 1.28+.
43It does not currently use any Rust 2018 features.
44
45### Breaking Changes
46
47Breaking changes are minimized. When they are made they will be outlined below with transition guidelines.
48
Danny Browning181d9002019-04-15 09:50:24 -060049##### Thrift 0.13.0
James E. King III057bebc2019-05-26 14:59:04 -040050
Danny Browning181d9002019-04-15 09:50:24 -060051* **[THRIFT-4536]** - Use TryFrom from std, required rust 1.34.0 or higher
52
53 Previously TryFrom was from try_from crate, it is now from the std library,
54 but this functionality is only available in rust 1.34.0. Additionally,
55 ordered-float is now re-exported under the thrift module to reduce
56 possible dependency mismatches.
57
GREATEST Wiggler EvaR!b57d1262018-11-09 07:54:32 -050058##### Thrift 0.12.0
59
60* **[THRIFT-4529]** - Rust enum variants are now camel-cased instead of uppercased to conform to Rust naming conventions
61
62 Previously, enum variants were uppercased in the auto-generated code.
63 For example, the following thrift enum:
64
65 ```thrift
66 // THRIFT
67 enum Operation {
68 ADD,
69 SUBTRACT,
70 MULTIPLY,
71 DIVIDE,
72 }
73 ```
74
75 used to generate:
76
77 ```rust
78 // OLD AUTO-GENERATED RUST
79 pub enum Operation {
80 ADD,
81 SUBTRACT,
82 MULTIPLY,
83 DIVIDE,
84 }
85 ```
86 It *now* generates:
87 ```rust
88 // NEW AUTO-GENERATED RUST
89 pub enum Operation {
90 Add,
91 Subtract,
92 Multiply,
93 Divide,
94 }
95 ```
96
97 You will have to change all enum variants in your code to use camel-cased names.
98 This should be a search and replace.
99
Allen George8b96bfb2016-11-02 08:01:08 -0400100## Contributing
101
102Bug reports and PRs are always welcome! Please see the
103[Thrift website](https://thrift.apache.org/) for more details.
104
105Thrift Rust support requires code in several directories:
106
107* `compiler/cpp/src/thrift/generate/t_rs_generator.cc`: binding code generator
108* `lib/rs`: runtime library
109* `lib/rs/test`: supplemental tests
110* `tutorial/rs`: tutorial client and server
111* `test/rs`: cross-language test client and server
112
113All library code, test code and auto-generated code compiles and passes clippy
114without warnings. All new code must do the same! When making changes ensure that:
115
116* `rustc` does does output any warnings
117* `clippy` with default settings does not output any warnings (includes auto-generated code)
118* `cargo test` is successful
119* `make precross` and `make check` are successful
120* `tutorial/bin/tutorial_client` and `tutorial/bin/tutorial_server` communicate