Skip to content

Commit 70867f1

Browse files
authored
doc: Document that the fields' order is important for "the serde way" (#242)
#227 (comment) Signed-off-by: Martin Tzvetanov Grigorov <[email protected]>
1 parent bd17691 commit 70867f1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

avro/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,18 @@ writer.append_ser(test).unwrap();
268268
let encoded = writer.into_inner();
269269
```
270270

271+
#### Importance of the fields' order
272+
273+
*Important*: The order of the fields in the struct must match the order of the fields in the Avro schema!
274+
275+
#### Simple types
276+
271277
The vast majority of the times, schemas tend to define a record as a top-level container
272278
encapsulating all the values to convert as fields and providing documentation for them, but in
273279
case we want to directly define an Avro value, any type implementing `Serialize` should work.
274280

275281
```rust
276-
let mut value = "foo".to_string();
282+
let value = "foo".to_string();
277283
```
278284

279285
### Using codecs to compress data

avro/src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,12 +283,18 @@
283283
//! let encoded = writer.into_inner();
284284
//! ```
285285
//!
286+
//! ### Importance of the fields' order
287+
//!
288+
//! *Important*: The order of the fields in the struct must match the order of the fields in the Avro schema!
289+
//!
290+
//! ### Simple types
291+
//!
286292
//! The vast majority of the times, schemas tend to define a record as a top-level container
287293
//! encapsulating all the values to convert as fields and providing documentation for them, but in
288294
//! case we want to directly define an Avro value, any type implementing `Serialize` should work.
289295
//!
290296
//! ```
291-
//! let mut value = "foo".to_string();
297+
//! let value = "foo".to_string();
292298
//! ```
293299
//!
294300
//! ## Using codecs to compress data

0 commit comments

Comments
 (0)