| Allen George | 8b96bfb | 2016-11-02 08:01:08 -0400 | [diff] [blame] | 1 | # Rust Thrift library |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | This crate implements the components required to build a working Thrift server |
| 6 | and 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 | |
| 14 | The modules are layered as shown. The `generated` layer is code generated by the |
| 15 | Thrift compiler's Rust plugin. It uses the components defined in this crate to |
| 16 | serialize and deserialize types and implement RPC. Users interact with these |
| 17 | types 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 | |
| 33 | Add `thrift = "x.y.z"` to your `Cargo.toml`, where `x.y.z` is the version of the |
| 34 | Thrift compiler you're using. |
| 35 | |
| 36 | ## API Documentation |
| 37 | |
| 38 | Full [Rustdoc](https://docs.rs/thrift/) |
| 39 | |
| GREATEST Wiggler EvaR! | b57d126 | 2018-11-09 07:54:32 -0500 | [diff] [blame] | 40 | ## Compatibility |
| 41 | |
| 42 | The Rust library and auto-generated code targets Rust versions 1.28+. |
| 43 | It does not currently use any Rust 2018 features. |
| 44 | |
| 45 | ### Breaking Changes |
| 46 | |
| 47 | Breaking changes are minimized. When they are made they will be outlined below with transition guidelines. |
| 48 | |
| Allen George | b0d1413 | 2020-03-29 11:48:55 -0400 | [diff] [blame] | 49 | ##### Thrift 0.14.0 |
| 50 | |
| Allen George | 7ddbcc0 | 2020-11-08 09:51:19 -0500 | [diff] [blame] | 51 | * **[THRIFT-5158]** - Rust library and generator now support Rust 2018 only. Required rust 1.40.0 or higher |
| Allen George | b0d1413 | 2020-03-29 11:48:55 -0400 | [diff] [blame] | 52 | |
| 53 | The Rust `thrift` library was updated to Rust 2018 via `cargo fix --edition`. |
| 54 | All test code in the repo was updated as well. The code generator was also updated |
| 55 | to support Rust 2018 only. |
| 56 | |
| Danny Browning | 181d900 | 2019-04-15 09:50:24 -0600 | [diff] [blame] | 57 | ##### Thrift 0.13.0 |
| James E. King III | 057bebc | 2019-05-26 14:59:04 -0400 | [diff] [blame] | 58 | |
| Danny Browning | 181d900 | 2019-04-15 09:50:24 -0600 | [diff] [blame] | 59 | * **[THRIFT-4536]** - Use TryFrom from std, required rust 1.34.0 or higher |
| 60 | |
| 61 | Previously TryFrom was from try_from crate, it is now from the std library, |
| 62 | but this functionality is only available in rust 1.34.0. Additionally, |
| 63 | ordered-float is now re-exported under the thrift module to reduce |
| 64 | possible dependency mismatches. |
| 65 | |
| GREATEST Wiggler EvaR! | b57d126 | 2018-11-09 07:54:32 -0500 | [diff] [blame] | 66 | ##### Thrift 0.12.0 |
| 67 | |
| 68 | * **[THRIFT-4529]** - Rust enum variants are now camel-cased instead of uppercased to conform to Rust naming conventions |
| 69 | |
| 70 | Previously, enum variants were uppercased in the auto-generated code. |
| 71 | For example, the following thrift enum: |
| 72 | |
| 73 | ```thrift |
| 74 | // THRIFT |
| 75 | enum Operation { |
| 76 | ADD, |
| 77 | SUBTRACT, |
| 78 | MULTIPLY, |
| 79 | DIVIDE, |
| 80 | } |
| 81 | ``` |
| 82 | |
| 83 | used to generate: |
| 84 | |
| 85 | ```rust |
| 86 | // OLD AUTO-GENERATED RUST |
| 87 | pub enum Operation { |
| 88 | ADD, |
| 89 | SUBTRACT, |
| 90 | MULTIPLY, |
| 91 | DIVIDE, |
| 92 | } |
| 93 | ``` |
| 94 | It *now* generates: |
| 95 | ```rust |
| 96 | // NEW AUTO-GENERATED RUST |
| 97 | pub enum Operation { |
| 98 | Add, |
| 99 | Subtract, |
| 100 | Multiply, |
| 101 | Divide, |
| 102 | } |
| 103 | ``` |
| 104 | |
| 105 | You will have to change all enum variants in your code to use camel-cased names. |
| 106 | This should be a search and replace. |
| 107 | |
| Allen George | 8b96bfb | 2016-11-02 08:01:08 -0400 | [diff] [blame] | 108 | ## Contributing |
| 109 | |
| 110 | Bug reports and PRs are always welcome! Please see the |
| 111 | [Thrift website](https://thrift.apache.org/) for more details. |
| 112 | |
| 113 | Thrift Rust support requires code in several directories: |
| 114 | |
| 115 | * `compiler/cpp/src/thrift/generate/t_rs_generator.cc`: binding code generator |
| 116 | * `lib/rs`: runtime library |
| 117 | * `lib/rs/test`: supplemental tests |
| 118 | * `tutorial/rs`: tutorial client and server |
| 119 | * `test/rs`: cross-language test client and server |
| 120 | |
| 121 | All library code, test code and auto-generated code compiles and passes clippy |
| 122 | without warnings. All new code must do the same! When making changes ensure that: |
| 123 | |
| 124 | * `rustc` does does output any warnings |
| 125 | * `clippy` with default settings does not output any warnings (includes auto-generated code) |
| 126 | * `cargo test` is successful |
| 127 | * `make precross` and `make check` are successful |
| 128 | * `tutorial/bin/tutorial_client` and `tutorial/bin/tutorial_server` communicate |