Parse a `serde_json::Value` representing a Avro union type into a `Schema`.
(
&mut self,
items: &[Value],
enclosing_namespace: NamespaceRef,
)
| 722 | declares the union with 'RUST_LOG=apache_avro::schema=debug'." |
| 723 | ); |
| 724 | } |
| 725 | Ok(Schema::Union(UnionSchema::new(schemas)?)) |
| 726 | }) |
| 727 | } |
| 728 | |
| 729 | /// Parse a `serde_json::Value` representing a Avro fixed type into a `Schema`. |
| 730 | fn parse_fixed( |
| 731 | &mut self, |
| 732 | mut complex: Map<String, Value>, |
| 733 | enclosing_namespace: NamespaceRef, |
| 734 | ) -> AvroResult<Schema> { |
| 735 | let size_opt = complex.remove("size"); |
| 736 | if size_opt.is_none() |
| 737 | && let Some(seen) = self.get_already_seen_schema(&complex, enclosing_namespace) |
| 738 | { |
| 739 | return Ok(seen.clone()); |
| 740 | } |
| 741 | |
| 742 | let doc = complex.string("doc")?; |
| 743 | |
| 744 | let size = match size_opt { |
| 745 | Some(Value::Number(size)) => size |
| 746 | .as_u64() |
| 747 | .ok_or(Details::GetFixedSizeFieldPositive(Value::Number(size))), |
| 748 | Some(v) => Err(Details::GetFixedSizeFieldInvalidType(v.description())), |
| 749 | None => Err(Details::GetFixedSizeField), |
| 750 | }?; |
| 751 | let size = usize::try_from(size).map_err(|e| Details::ConvertU64ToUsize(e, size))?; |
| 752 | let fully_qualified_name = Name::parse(&mut complex, enclosing_namespace)?; |