martin-g commented on code in PR #190:
URL: https://github.com/apache/avro-rs/pull/190#discussion_r2060979082


##########
avro/src/headers.rs:
##########
@@ -0,0 +1,134 @@
+use uuid::Uuid;
+
+use crate::{rabin::Rabin, schema::SchemaFingerprint, AvroResult, Schema};
+
+pub trait HeaderBuilder {
+    fn build_header(&self) -> Vec<u8>;
+}
+
+pub struct RabinFingerprintHeader {
+    fingerprint: SchemaFingerprint,
+}
+
+impl RabinFingerprintHeader {
+    pub fn create_from_schema(schema: &Schema) -> Self {
+        let fingerprint = schema.fingerprint::<Rabin>();
+        RabinFingerprintHeader { fingerprint }
+    }
+}
+
+impl HeaderBuilder for RabinFingerprintHeader {
+    fn build_header(&self) -> Vec<u8> {
+        vec![
+            0xC3,
+            0x01,
+            self.fingerprint.bytes[0],
+            self.fingerprint.bytes[1],
+            self.fingerprint.bytes[2],
+            self.fingerprint.bytes[3],
+            self.fingerprint.bytes[4],
+            self.fingerprint.bytes[5],
+            self.fingerprint.bytes[6],
+            self.fingerprint.bytes[7],
+        ]
+    }
+}
+
+pub struct GlueSchemaUuidHeader {
+    schema_uuid: Uuid,
+}
+
+impl GlueSchemaUuidHeader {
+    pub fn create_from_uuid(schema_uuid: Uuid) -> Self {

Review Comment:
   ```suggestion
       pub fn from_uuid(schema_uuid: Uuid) -> Self {
   ```
   



##########
avro/src/headers.rs:
##########
@@ -0,0 +1,134 @@
+use uuid::Uuid;
+
+use crate::{rabin::Rabin, schema::SchemaFingerprint, AvroResult, Schema};
+
+pub trait HeaderBuilder {
+    fn build_header(&self) -> Vec<u8>;
+}
+
+pub struct RabinFingerprintHeader {
+    fingerprint: SchemaFingerprint,
+}
+
+impl RabinFingerprintHeader {
+    pub fn create_from_schema(schema: &Schema) -> Self {

Review Comment:
   ```suggestion
       pub fn from_schema(schema: &Schema) -> Self {
   ```
   



##########
avro/src/headers.rs:
##########
@@ -0,0 +1,134 @@
+use uuid::Uuid;
+
+use crate::{rabin::Rabin, schema::SchemaFingerprint, AvroResult, Schema};
+
+pub trait HeaderBuilder {

Review Comment:
   Please add rustdoc to all public items 



##########
avro/src/reader.rs:
##########
@@ -1034,6 +1031,24 @@ mod tests {
         Ok(())
     }
 
+    #[test]
+    fn test_avro_generic_reader_alternate_header() -> TestResult {

Review Comment:
   ```suggestion
       fn avro_rs_164_generic_reader_alternate_header() -> TestResult {
   ```
   



-- 
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