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 2026/01/19 08:31:36 UTC

(avro-rs) branch extract_record_schema_in_its_own_module created (now 25242a1)

This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a change to branch extract_record_schema_in_its_own_module
in repository https://gitbox.apache.org/repos/asf/avro-rs.git


      at 25242a1  chore: Extract RecordSchema into its own module (src/schema/record/schema.rs)

This branch includes the following new commits:

     new 25242a1  chore: Extract RecordSchema into its own module (src/schema/record/schema.rs)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(avro-rs) 01/01: chore: Extract RecordSchema into its own module (src/schema/record/schema.rs)

Posted by mg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mgrigorov pushed a commit to branch extract_record_schema_in_its_own_module
in repository https://gitbox.apache.org/repos/asf/avro-rs.git

commit 25242a124afbd9ed1f34617d7c5efc8a07db892a
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
AuthorDate: Mon Jan 19 10:30:41 2026 +0200

    chore: Extract RecordSchema into its own module (src/schema/record/schema.rs)
---
 avro/src/schema/mod.rs           | 36 ++++------------------------
 avro/src/schema/record/mod.rs    |  4 ++++
 avro/src/schema/record/schema.rs | 51 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 32 deletions(-)

diff --git a/avro/src/schema/mod.rs b/avro/src/schema/mod.rs
index 184e2c9..25319f7 100644
--- a/avro/src/schema/mod.rs
+++ b/avro/src/schema/mod.rs
@@ -41,7 +41,10 @@ use std::{
 use strum_macros::{Display, EnumDiscriminants};
 
 mod record;
-pub use crate::schema::record::{RecordField, RecordFieldBuilder, RecordFieldOrder};
+use crate::schema::record::RecordSchemaParseLocation;
+pub use crate::schema::record::{
+    RecordField, RecordFieldBuilder, RecordFieldOrder, RecordSchema, RecordSchemaBuilder,
+};
 
 /// Represents an Avro schema fingerprint
 /// More information about Avro schema fingerprints can be found in the
@@ -640,27 +643,6 @@ pub(crate) fn resolve_names_with_schemata(
     Ok(())
 }
 
-/// A description of a Record schema.
-#[derive(bon::Builder, Debug, Clone)]
-pub struct RecordSchema {
-    /// The name of the schema
-    pub name: Name,
-    /// The aliases of the schema
-    #[builder(default)]
-    pub aliases: Aliases,
-    /// The documentation of the schema
-    #[builder(default)]
-    pub doc: Documentation,
-    /// The set of fields of the schema
-    pub fields: Vec<RecordField>,
-    /// The `lookup` table maps field names to their position in the `Vec`
-    /// of `fields`.
-    pub lookup: BTreeMap<String, usize>,
-    /// The custom attributes of the schema
-    #[builder(default = BTreeMap::new())]
-    pub attributes: BTreeMap<String, Value>,
-}
-
 /// A description of an Enum schema.
 #[derive(bon::Builder, Debug, Clone)]
 pub struct EnumSchema {
@@ -915,16 +897,6 @@ fn parse_json_integer_for_decimal(value: &serde_json::Number) -> Result<DecimalM
     })
 }
 
-#[derive(Debug, Default)]
-enum RecordSchemaParseLocation {
-    /// When the parse is happening at root level
-    #[default]
-    Root,
-
-    /// When the parse is happening inside a record field
-    FromField,
-}
-
 #[derive(Default)]
 pub(crate) struct Parser {
     input_schemas: HashMap<Name, Value>,
diff --git a/avro/src/schema/record/mod.rs b/avro/src/schema/record/mod.rs
index 9ba59f5..0d1c5a1 100644
--- a/avro/src/schema/record/mod.rs
+++ b/avro/src/schema/record/mod.rs
@@ -17,3 +17,7 @@
 
 mod field;
 pub use field::{RecordField, RecordFieldBuilder, RecordFieldOrder};
+
+mod schema;
+pub(crate) use schema::RecordSchemaParseLocation;
+pub use schema::{RecordSchema, RecordSchemaBuilder};
diff --git a/avro/src/schema/record/schema.rs b/avro/src/schema/record/schema.rs
new file mode 100644
index 0000000..28a30a6
--- /dev/null
+++ b/avro/src/schema/record/schema.rs
@@ -0,0 +1,51 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::schema::{Aliases, Documentation, Name, RecordField};
+use serde_json::Value;
+use std::collections::BTreeMap;
+
+/// A description of a Record schema.
+#[derive(bon::Builder, Debug, Clone)]
+pub struct RecordSchema {
+    /// The name of the schema
+    pub name: Name,
+    /// The aliases of the schema
+    #[builder(default)]
+    pub aliases: Aliases,
+    /// The documentation of the schema
+    #[builder(default)]
+    pub doc: Documentation,
+    /// The set of fields of the schema
+    pub fields: Vec<RecordField>,
+    /// The `lookup` table maps field names to their position in the `Vec`
+    /// of `fields`.
+    pub lookup: BTreeMap<String, usize>,
+    /// The custom attributes of the schema
+    #[builder(default = BTreeMap::new())]
+    pub attributes: BTreeMap<String, Value>,
+}
+
+#[derive(Debug, Default)]
+pub(crate) enum RecordSchemaParseLocation {
+    /// When the parse is happening at root level
+    #[default]
+    Root,
+
+    /// When the parse is happening inside a record field
+    FromField,
+}