Implement wasm_bindgen conversion traits for Uuid #844
Labels
No labels
breaking
bug
dependencies
good first issue
help wanted
unstable
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-uuid-rs/uuid#844
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi! I read #653, and I was wondering if I could submit a simple PR implementing the conversion traits (like
FromWasmAbiand friends) that just treats aUuidto a string (converting it to and from Rust with Uuid'sFromStrandDisplayimpls). I think this is reasonable given that the JavaScript standard library produces v4 UUIDs as strings by default.If this makes sense, I'd love to submit a PR with these trait implementations!
Thanks for pointing that out @demhadais. That's certainly a point in favor of representing UUIDs as strings, but still isn't a single obviously correct representation for all possible users. I would be in favor of implementing the traits on our formatting adapters like
Hyphenatedthat represented them as strings as a starting point.@KodrAus I see - that makes sense to me. I'll get started on a PR, though you should note that the
wasm-bindgenmodule in which these traits reside is explicitly marked as "unstable". Specifically, "no stability guarantees are provided". I thought this wasn't an issue, but the maintainer ofjiff(a datetime crate) brought up good points in Burntsushi/jiff#424 because I wanted to submit a similar PR for the types in that crate. To summarize, even minor version upgrades might present breaking changes, which could pose a problem for uuid. I'm not sure how much of a problem that's actually going to be; taking a cursory glance at the history of this module, I don't see much actual change - it's mostly documentation stuff and non-breaking changes.In any case, I did submit wasm-bindgen/wasm-bindgen#4726, but if you'd prefer to wait for a response to that issue and see if there are stronger semver-compatibility guarantees, that would also make sense to me.
Thanks!
Ah yes, without
wasm-bindgenbeing stable we’d need to add this behind a feature flag and using a compiler variable the same way we do forzerocopy. If you did want to take a crack at this I can give you some pointers on how that works.+1. This feature would be really useful.
Currently, I convert the
Uuidtype manually, which is a bit verbose and repetitive:Being able to declare methods like
fn undo(&self, pattern_id: &uuid::Uuid)(or an owned type) will remove much boilerplate from my code.