From 24efe48d060c94574ef9d79f634670a439beb633 Mon Sep 17 00:00:00 2001 From: Fedor Telnov Date: Fri, 19 May 2023 09:48:04 +0300 Subject: [PATCH] feat: add an examples of how refactoring may look like --- lang/rust/avro/src/schema.rs | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/lang/rust/avro/src/schema.rs b/lang/rust/avro/src/schema.rs index a035a55ca5a..591579141ce 100644 --- a/lang/rust/avro/src/schema.rs +++ b/lang/rust/avro/src/schema.rs @@ -64,6 +64,25 @@ impl fmt::Display for SchemaFingerprint { } } +// Just an example of how it may look like +struct RecordSchema { + name: Name, + aliases: Aliases, + doc: Documentation, + fields: Vec, + lookup: BTreeMap, + attributes: BTreeMap, +} + +// Just an example of how it may look like +struct EnumSchema { + name: Name, + aliases: Aliases, + doc: Documentation, + symbols: Vec, + attributes: BTreeMap, +} + /// Represents any valid Avro schema /// More information about Avro schemas can be found in the /// [Avro Specification](https://avro.apache.org/docs/current/spec.html#schemas) @@ -101,22 +120,9 @@ pub enum Schema { /// /// The `lookup` table maps field names to their position in the `Vec` /// of `fields`. - Record { - name: Name, - aliases: Aliases, - doc: Documentation, - fields: Vec, - lookup: BTreeMap, - attributes: BTreeMap, - }, + Record(RecordSchema), /// An `enum` Avro schema. - Enum { - name: Name, - aliases: Aliases, - doc: Documentation, - symbols: Vec, - attributes: BTreeMap, - }, + Enum(EnumSchema), /// A `fixed` Avro schema. Fixed { name: Name,