You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by mg...@apache.org on 2025/07/25 07:16:09 UTC
(avro-rs) 01/01: doc: Document that the fields' order is important for "the serde way"
This is an automated email from the ASF dual-hosted git repository.
mgrigorov pushed a commit to branch fields-order-importance
in repository https://gitbox.apache.org/repos/asf/avro-rs.git
commit b0ab323948a86592ccac22c6fe8b07edacc7d0bf
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Fri Jul 25 10:15:16 2025 +0300
doc: Document that the fields' order is important for "the serde way"
https://github.com/apache/avro-rs/pull/227#issuecomment-3116660601
Signed-off-by: Martin Tzvetanov Grigorov <mg...@apache.org>
---
avro/README.md | 8 +++++++-
avro/src/lib.rs | 8 +++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/avro/README.md b/avro/README.md
index 0b2325b..96417b1 100644
--- a/avro/README.md
+++ b/avro/README.md
@@ -268,12 +268,18 @@ writer.append_ser(test).unwrap();
let encoded = writer.into_inner();
```
+#### Importance of the fields' order
+
+*Important*: The order of the fields in the struct must match the order of the fields in the Avro schema!
+
+#### Simple types
+
The vast majority of the times, schemas tend to define a record as a top-level container
encapsulating all the values to convert as fields and providing documentation for them, but in
case we want to directly define an Avro value, any type implementing `Serialize` should work.
```rust
-let mut value = "foo".to_string();
+let value = "foo".to_string();
```
### Using codecs to compress data
diff --git a/avro/src/lib.rs b/avro/src/lib.rs
index 225cbc1..6836b73 100644
--- a/avro/src/lib.rs
+++ b/avro/src/lib.rs
@@ -283,12 +283,18 @@
//! let encoded = writer.into_inner();
//! ```
//!
+//! ### Importance of the fields' order
+//!
+//! *Important*: The order of the fields in the struct must match the order of the fields in the Avro schema!
+//!
+//! ### Simple types
+//!
//! The vast majority of the times, schemas tend to define a record as a top-level container
//! encapsulating all the values to convert as fields and providing documentation for them, but in
//! case we want to directly define an Avro value, any type implementing `Serialize` should work.
//!
//! ```
-//! let mut value = "foo".to_string();
+//! let value = "foo".to_string();
//! ```
//!
//! ## Using codecs to compress data