Skip to content

Commit 12eaa17

Browse files
authored
[Minor]: Document visibility for enums produced by Thrift macros (#8706)
# Which issue does this PR close? N/A # Rationale for this change It is not obvious that the thrift macros produce public enums only (e.g. see #8680 (comment)). This should be made clear in the documentation. # What changes are included in this PR? Add said clarification. # Are these changes tested? Documentation only, so no tests required. # Are there any user-facing changes? No, only changes to private documentation
1 parent d519bb8 commit 12eaa17

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

parquet/THRIFT.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ The `thrift_enum` macro can be used in this instance.
5757

5858
```rust
5959
thrift_enum!(
60-
enum Type {
60+
enum Type {
6161
BOOLEAN = 0;
6262
INT32 = 1;
6363
INT64 = 2;
@@ -85,6 +85,8 @@ pub enum Type {
8585
}
8686
```
8787

88+
All Rust `enum`s produced with this macro will have `pub` visibility.
89+
8890
### Unions
8991

9092
Thrift unions are a special kind of struct in which only a single field is populated. In this
@@ -175,6 +177,9 @@ pub enum ColumnCryptoMetaData {
175177
}
176178
```
177179

180+
All Rust `enum`s produced with either macro will have `pub` visibility. `thrift_union` also allows
181+
for lifetime annotations, but this capability is not currently utilized.
182+
178183
### Structs
179184

180185
The `thrift_struct` macro is used for structs. This macro is a little more flexible than the others

parquet/src/parquet_macros.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@
3636
#[allow(clippy::crate_in_macro_def)]
3737
/// Macro used to generate rust enums from a Thrift `enum` definition.
3838
///
39-
/// When utilizing this macro the Thrift serialization traits and structs need to be in scope.
39+
/// Note:
40+
/// - All enums generated with this macro will have `pub` visibility.
41+
/// - When utilizing this macro the Thrift serialization traits and structs need to be in scope.
4042
macro_rules! thrift_enum {
4143
($(#[$($def_attrs:tt)*])* enum $identifier:ident { $($(#[$($field_attrs:tt)*])* $field_name:ident = $field_value:literal;)* }) => {
4244
$(#[$($def_attrs)*])*
@@ -91,7 +93,9 @@ macro_rules! thrift_enum {
9193
///
9294
/// The resulting Rust enum will have all unit variants.
9395
///
94-
/// When utilizing this macro the Thrift serialization traits and structs need to be in scope.
96+
/// Note:
97+
/// - All enums generated with this macro will have `pub` visibility.
98+
/// - When utilizing this macro the Thrift serialization traits and structs need to be in scope.
9599
#[doc(hidden)]
96100
#[macro_export]
97101
#[allow(clippy::crate_in_macro_def)]
@@ -162,9 +166,10 @@ macro_rules! thrift_union_all_empty {
162166
/// non-empty type, the typename must be contained within parens (e.g. `1: MyType Var1;` becomes
163167
/// `1: (MyType) Var1;`).
164168
///
165-
/// This macro allows for specifying lifetime annotations for the resulting `enum` and its fields.
166-
///
167-
/// When utilizing this macro the Thrift serialization traits and structs need to be in scope.
169+
/// Note:
170+
/// - All enums generated with this macro will have `pub` visibility.
171+
/// - This macro allows for specifying lifetime annotations for the resulting `enum` and its fields.
172+
/// - When utilizing this macro the Thrift serialization traits and structs need to be in scope.
168173
#[doc(hidden)]
169174
#[macro_export]
170175
#[allow(clippy::crate_in_macro_def)]
@@ -228,9 +233,11 @@ macro_rules! thrift_union {
228233

229234
/// Macro used to generate Rust structs from a Thrift `struct` definition.
230235
///
231-
/// This macro allows for specifying lifetime annotations for the resulting `struct` and its fields.
232-
///
233-
/// When utilizing this macro the Thrift serialization traits and structs need to be in scope.
236+
/// Note:
237+
/// - This macro allows for specifying the visibility of the resulting `struct` and its fields.
238+
/// + The `struct` and all fields will have the same visibility.
239+
/// - This macro allows for specifying lifetime annotations for the resulting `struct` and its fields.
240+
/// - When utilizing this macro the Thrift serialization traits and structs need to be in scope.
234241
#[doc(hidden)]
235242
#[macro_export]
236243
macro_rules! thrift_struct {

0 commit comments

Comments
 (0)