martin-g commented on code in PR #255:
URL: https://github.com/apache/avro-rs/pull/255#discussion_r2265741151
##########
avro/src/decode.rs:
##########
@@ -123,61 +121,18 @@ pub(crate) fn decode_internal<R: Read, S: Borrow<Schema>>(
}
}
Schema::Uuid => {
- let len = decode_len(reader)?;
- let mut bytes = vec![0u8; len];
- reader
- .read_exact(&mut bytes)
- .map_err(Details::ReadIntoBuf)?;
-
- // use a Vec to be able re-read the bytes more than once if needed
- let mut reader = Vec::with_capacity(len + 1);
- encode_long(len as i64, &mut reader)?;
- reader.extend_from_slice(&bytes);
-
- let decode_from_string = |reader| match decode_internal(
- &Schema::String,
- names,
- enclosing_namespace,
- reader,
- )? {
- Value::String(ref s) => {
- Uuid::from_str(s).map_err(|e|
Details::ConvertStrToUuid(e).into())
- }
- value =>
Err(Error::new(Details::GetUuidFromStringValue(value))),
+ let Value::Bytes(bytes) =
+ decode_internal(&Schema::Bytes, names, enclosing_namespace,
reader)?
+ else {
+ // Calling decode_internal with Schema::Bytes can only return
a Value::Bytes or an error
Review Comment:
do we need the `else` at all ?
--
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]