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


##########
avro/src/decode.rs:
##########
@@ -101,39 +102,66 @@ pub(crate) fn decode_internal<R: Read, S: Borrow<Schema>>(
                 }
             }
         }
-        Schema::Decimal(DecimalSchema { ref inner, .. }) => match &**inner {
-            Schema::Fixed { .. } => {
-                match decode_internal(inner, names, enclosing_namespace, 
reader)? {
+        Schema::Decimal(DecimalSchema { inner, .. }) => match inner {
+            InnerDecimalSchema::Fixed(fixed) => {
+                match decode_internal(
+                    &Schema::Fixed(fixed.copy_only_size()),
+                    names,
+                    enclosing_namespace,
+                    reader,
+                )? {
                     Value::Fixed(_, bytes) => 
Ok(Value::Decimal(Decimal::from(bytes))),
                     value => Err(Details::FixedValue(value).into()),
                 }
             }
-            Schema::Bytes => match decode_internal(inner, names, 
enclosing_namespace, reader)? {
-                Value::Bytes(bytes) => 
Ok(Value::Decimal(Decimal::from(bytes))),
-                value => Err(Details::BytesValue(value).into()),
-            },
-            schema => Err(Details::ResolveDecimalSchema(schema.into()).into()),
+            InnerDecimalSchema::Bytes => {
+                match decode_internal(&Schema::Bytes, names, 
enclosing_namespace, reader)? {
+                    Value::Bytes(bytes) => 
Ok(Value::Decimal(Decimal::from(bytes))),
+                    value => Err(Details::BytesValue(value).into()),
+                }
+            }
         },
         Schema::BigDecimal => {
             match decode_internal(&Schema::Bytes, names, enclosing_namespace, 
reader)? {
                 Value::Bytes(bytes) => 
deserialize_big_decimal(&bytes).map(Value::BigDecimal),
                 value => Err(Details::BytesValue(value).into()),
             }
         }
-        Schema::Uuid => {
+        Schema::Uuid(UuidSchema::String) => {
+            let Value::String(string) =
+                decode_internal(&Schema::String, names, enclosing_namespace, 
reader)?
+            else {
+                // Calling decode_internal with Schema::String can only return 
a Value::String or an error

Review Comment:
   Hmm, you're right. Why are we doing that? We only do it for String and Union.



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