-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
serde serialize_with support #735
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! This looks good to me @dakaizou.
I don't think we need to do deserialize_with
support, since the parser will very quickly identify the appropriate format to use. We can also add deserialize support in a non-breaking way in the future if we want to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, having another look at the existing compact
module, I think we should follow the same pattern here. Instead of top-level functions in uuid::serde
, let's use modules with a serialize
and deserialize
function in them.
This was exactly what I was thinking, since they can all be deserialized with
If not, I will just proxy the function call: pub fn deserialize<'de, D>(deserializer: D) -> Result<crate::Uuid, D::Error>
where
D: serde::Deserializer<'de>,
{
serde::Deserialize::deserialize(deserializer)
} |
I think we should only parse exactly the format requested. It looks like we don't have exposed methods for specific parsers, but we could make them |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting this together @dakaizou! This is some great work 🙂
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [uuid](https://togithub.com/uuid-rs/uuid) | workspace.dependencies | minor | `1.7.0` -> `1.8.0` | --- ### Release Notes <details> <summary>uuid-rs/uuid (uuid)</summary> ### [`v1.8.0`](https://togithub.com/uuid-rs/uuid/releases/tag/1.8.0) [Compare Source](https://togithub.com/uuid-rs/uuid/compare/1.7.0...1.8.0) ####⚠️ Potential Breakage⚠️ A new `impl AsRef<Uuid> for Uuid` bound has been added, which can break inference on code like: ```rust let b = uuid.as_ref(); ``` You can fix these by explicitly typing the result of the conversion: ```rust let b: &[u8] = uuid.as_ref(); ``` or by calling `as_bytes` instead: ```rust let b = uuid.as_bytes(); ``` #### What's Changed - docs: fix small spelling mistake by [@​bengsparks](https://togithub.com/bengsparks) in [https://github.com/uuid-rs/uuid/pull/737](https://togithub.com/uuid-rs/uuid/pull/737) - serde serialize_with support by [@​dakaizou](https://togithub.com/dakaizou) in [https://github.com/uuid-rs/uuid/pull/735](https://togithub.com/uuid-rs/uuid/pull/735) - Fix up CI builds by [@​KodrAus](https://togithub.com/KodrAus) in [https://github.com/uuid-rs/uuid/pull/744](https://togithub.com/uuid-rs/uuid/pull/744) - Only add `wasm-bindgen` as a dependency on `wasm32-unknown-unknown` by [@​emilk](https://togithub.com/emilk) in [https://github.com/uuid-rs/uuid/pull/738](https://togithub.com/uuid-rs/uuid/pull/738) - impl AsRef<Uuid> for Uuid by [@​koshell](https://togithub.com/koshell) in [https://github.com/uuid-rs/uuid/pull/743](https://togithub.com/uuid-rs/uuid/pull/743) - Add v6 to v8 draft link to README by [@​KodrAus](https://togithub.com/KodrAus) in [https://github.com/uuid-rs/uuid/pull/746](https://togithub.com/uuid-rs/uuid/pull/746) - Add a workflow for running cargo outdated by [@​KodrAus](https://togithub.com/KodrAus) in [https://github.com/uuid-rs/uuid/pull/745](https://togithub.com/uuid-rs/uuid/pull/745) - Prepare for 1.8.0 release by [@​KodrAus](https://togithub.com/KodrAus) in [https://github.com/uuid-rs/uuid/pull/747](https://togithub.com/uuid-rs/uuid/pull/747) #### New Contributors - [@​bengsparks](https://togithub.com/bengsparks) made their first contribution in [https://github.com/uuid-rs/uuid/pull/737](https://togithub.com/uuid-rs/uuid/pull/737) - [@​dakaizou](https://togithub.com/dakaizou) made their first contribution in [https://github.com/uuid-rs/uuid/pull/735](https://togithub.com/uuid-rs/uuid/pull/735) - [@​emilk](https://togithub.com/emilk) made their first contribution in [https://github.com/uuid-rs/uuid/pull/738](https://togithub.com/uuid-rs/uuid/pull/738) - [@​koshell](https://togithub.com/koshell) made their first contribution in [https://github.com/uuid-rs/uuid/pull/743](https://togithub.com/uuid-rs/uuid/pull/743) **Full Changelog**: uuid-rs/uuid@1.7.0...1.8.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/andrzejressel/pulumi-wasm).
Bumps uuid from 1.7.0 to 1.8.0. Release notes Sourced from uuid's releases. 1.8.0⚠️ Potential Breakage⚠️ A new impl AsRef<Uuid> for Uuid bound has been added, which can break inference on code like: let b = uuid.as_ref(); You can fix these by explicitly typing the result of the conversion: let b: &[u8] = uuid.as_ref(); or by calling as_bytes instead: let b = uuid.as_bytes(); What's Changed docs: fix small spelling mistake by @bengsparks in uuid-rs/uuid#737 serde serialize_with support by @dakaizou in uuid-rs/uuid#735 Fix up CI builds by @KodrAus in uuid-rs/uuid#744 Only add wasm-bindgen as a dependency on wasm32-unknown-unknown by @emilk in uuid-rs/uuid#738 impl AsRef for Uuid by @koshell in uuid-rs/uuid#743 Add v6 to v8 draft link to README by @KodrAus in uuid-rs/uuid#746 Add a workflow for running cargo outdated by @KodrAus in uuid-rs/uuid#745 Prepare for 1.8.0 release by @KodrAus in uuid-rs/uuid#747 New Contributors @bengsparks made their first contribution in uuid-rs/uuid#737 @dakaizou made their first contribution in uuid-rs/uuid#735 @emilk made their first contribution in uuid-rs/uuid#738 @koshell made their first contribution in uuid-rs/uuid#743 Full Changelog: uuid-rs/[email protected] Commits 0f2aaae Merge pull request #747 from uuid-rs/cargo/1.8.0 01d16c3 prepare for 1.8.0 release e4746bc Merge pull request #745 from uuid-rs/ci/outdated d0396ad Merge pull request #746 from uuid-rs/chore/draft-link 9415ed4 Merge pull request #743 from koshell/main 951e8e3 Merge pull request #738 from rerun-io/emilk/wasm-bindgen-only-on-web 101aa84 add v6 to v8 draft link to README 84dcbba run outdated on a schedule ca952b1 add a workflow for running cargo outdated abe995a Make the toml longer, more complicated, and functional Additional commits viewable in compare view Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase. Dependabot commands and options You can trigger Dependabot actions by commenting on this PR: @dependabot rebase will rebase this PR @dependabot recreate will recreate this PR, overwriting any edits that have been made to it @dependabot merge will merge this PR after your CI passes on it @dependabot squash and merge will squash and merge this PR after your CI passes on it @dependabot cancel merge will cancel a previously requested merge and block automerging @dependabot reopen will reopen this PR if it is closed @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
I'm submitting a feature
Description
Adds the ability to serialize a
Uuid
as aSimple
/Urn
/Braced
.Uuid::parse_str
deserialize them correctly, butUuid
is always serialized asHyphenated
. Users would be able to decide which format to serialize to after this PR.Example:
Tests
3 new tests for the feature were added.
crate::external::serde_support::serde_tests::test_serialize_as_simple
crate::external::serde_support::serde_tests::test_serialize_as_braced
crate::external::serde_support::serde_tests::test_serialize_as_urn
Related Issue(s)
Before this issue is resolved, types like
Option<Uuid>
require their own functions to be serialized correctly.