Skip to content

Conversation

@Fokko
Copy link
Contributor

@Fokko Fokko commented Nov 3, 2025

Which issue does this PR close?

What changes are included in this PR?

Are these changes tested?

@mbutrovich
Copy link
Contributor

I will review this tomorrow.

Copy link
Contributor

@mbutrovich mbutrovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor comment, but this otherwise looks good to me. Thank you @Fokko!

Thank you for the test cases too!

Copy link
Contributor

@liurenjie1024 liurenjie1024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Fokko for this pr!

Type::decimal_required_bytes(*precision).map_err(|e| {
invalid_err_with_reason(
"bytes",
&format!("Invalid decimal precision: {}", e),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this error message is reduntant and will hide error message from decimal_required_bytes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good one 👍

))
}
}
_ => Err(invalid_err("bytes")),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to include target type in the error message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing it, but I think this is in line with the other branches, for example, list:

_ => Err(invalid_err("list")),

This then gets formatted in a nice message:

let invalid_err = |v: &str| {
Error::new(
ErrorKind::DataInvalid,
format!(
"Unable to convert raw literal ({v}) fail convert to type {ty} for: type mismatch"
),
)
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tracking: ser/se for bytes-like type

3 participants