Kriskras99 commented on code in PR #472:
URL: https://github.com/apache/avro-rs/pull/472#discussion_r2828131331


##########
avro/src/reader.rs:
##########
@@ -337,57 +338,39 @@ pub struct Reader<'a, R> {
     should_resolve_schema: bool,
 }
 
+#[bon]
 impl<'a, R: Read> Reader<'a, R> {
-    /// Creates a `Reader` given something implementing the `io::Read` trait 
to read from.
-    /// No reader `Schema` will be set.
-    ///
-    /// **NOTE** The avro header is going to be read automatically upon 
creation of the `Reader`.
     pub fn new(reader: R) -> AvroResult<Reader<'a, R>> {
-        let block = Block::new(reader, vec![])?;
-        let reader = Reader {
-            block,
-            reader_schema: None,
-            errored: false,
-            should_resolve_schema: false,
-        };
-        Ok(reader)
-    }
-
-    /// Creates a `Reader` given a reader `Schema` and something implementing 
the `io::Read` trait
-    /// to read from.
-    ///
-    /// **NOTE** The avro header is going to be read automatically upon 
creation of the `Reader`.
-    pub fn with_schema(schema: &'a Schema, reader: R) -> AvroResult<Reader<'a, 
R>> {
-        let block = Block::new(reader, vec![schema])?;
-        let mut reader = Reader {
-            block,
-            reader_schema: Some(schema),
-            errored: false,
-            should_resolve_schema: false,
-        };
-        // Check if the reader and writer schemas disagree.
-        reader.should_resolve_schema = reader.writer_schema() != schema;
-        Ok(reader)
+        Reader::builder(reader).build()
     }
-
-    /// Creates a `Reader` given a reader `Schema` and something implementing 
the `io::Read` trait
-    /// to read from.
+    /// Creates a `Reader` given something implementing the `io::Read` trait 
to read from.
+    /// With an optional reader `Schema` and optional schemata to use for 
resolving schema
+    /// references.
     ///
     /// **NOTE** The avro header is going to be read automatically upon 
creation of the `Reader`.
-    pub fn with_schemata(
-        schema: &'a Schema,
-        schemata: Vec<&'a Schema>,
-        reader: R,
+    #[builder(finish_fn = build)]
+    pub fn builder(
+        #[builder(start_fn)] reader: R,
+        schema: Option<&'a Schema>,

Review Comment:
   Maybe rename this to `reader_schema`, so it's clearer that this is not the 
writer schema



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to