From b0ab323948a86592ccac22c6fe8b07edacc7d0bf Mon Sep 17 00:00:00 2001 From: Martin Tzvetanov Grigorov Date: Fri, 25 Jul 2025 10:15:16 +0300 Subject: [PATCH] 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 --- 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 0b2325b9..96417b17 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 225cbc13..6836b73d 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