Kriskras99 commented on code in PR #339:
URL: https://github.com/apache/avro-rs/pull/339#discussion_r2598347144
##########
avro/src/schema.rs:
##########
@@ -894,7 +911,40 @@ pub struct DecimalSchema {
/// The number of digits to the right of the decimal point
pub scale: DecimalMetadata,
/// The inner schema of the decimal (fixed or bytes)
- pub inner: Box<Schema>,
+ pub inner: InnerDecimalSchema,
+}
+
+/// The inner schema of the Decimal type.
+#[derive(Debug, Clone)]
+pub enum InnerDecimalSchema {
+ Bytes,
+ Fixed(FixedSchema),
+}
+
+impl TryFrom<Schema> for InnerDecimalSchema {
+ type Error = Error;
+
+ fn try_from(value: Schema) -> Result<Self, Self::Error> {
+ match value {
+ Schema::Bytes => Ok(InnerDecimalSchema::Bytes),
+ Schema::Fixed(fixed) => Ok(InnerDecimalSchema::Fixed(fixed)),
+ _ => Err(Details::ResolveDecimalSchema(value.into()).into()),
+ }
+ }
+}
+
+/// The inner schema of the Uuid type.
+#[derive(Debug, Clone)]
Review Comment:
No the problem is with SchemaKind and Schema, a possible change is replacing
the `_ => unreachable!(..)` with:
```
Schema::Null
| Schema::Boolean
| Schema::Int
| Schema::Long
| Schema::Float
| Schema::Double
| Schema::Bytes
| Schema::String
| Schema::Array(_)
| Schema::Map(_)
| Schema::Union(_)
| Schema::Record(_)
| Schema::Enum(_)
| Schema::Fixed(_)
| Schema::Decimal(_)
| Schema::BigDecimal
| Schema::Date
| Schema::TimeMillis
| Schema::TimeMicros
| Schema::TimestampMillis
| Schema::TimestampMicros
| Schema::TimestampNanos
| Schema::LocalTimestampMillis
| Schema::LocalTimestampMicros
| Schema::LocalTimestampNanos
| Schema::Duration
| Schema::Ref { .. } => {
unreachable!("SchemaKind::Uuid can only be a Schema::Uuid")
}
```
--
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]