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


##########
avro/src/schema.rs:
##########
@@ -2629,7 +2663,6 @@ pub mod derive {
     impl_schema!(f64, Schema::Double);
     impl_schema!(String, Schema::String);
     impl_schema!(uuid::Uuid, Schema::Uuid(UuidSchema::String));
-    impl_schema!(core::time::Duration, Schema::Duration);

Review Comment:
   The old code generated the following schema:
   ```json
   {"type":{"name":"duration","type":"fixed","size":12}}
   ```
   I think it would be good to keep it:
   ```rust
   impl AvroSchemaComponent for core::time::Duration {
       fn get_schema_in_ctxt(
           named_schemas: &mut HashMap<String, Schema>,
           enclosing_namespace: &Namespace,
       ) -> Schema {
           let name = Name {
               name: "duration".to_string(),
               namespace: enclosing_namespace.clone(),
           };
           named_schemas
               .entry(name.to_string())
               .or_insert(Schema::Duration(FixedSchema {
                   name,
                   aliases: None,
                   doc: None,
                   size: 12,
                   default: None,
                   attributes: Default::default(),
               }))
               .clone()
       }
   }
   ```
   This is not an exact match if `enclosing_namespace` is not `None`, but I 
think this is the best option.



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