uuid-rs / uuid

Generate and parse UUIDs.

Home Page:https://www.crates.io/crates/uuid

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compilation error with wasm_bindgen

barvirm opened this issue · comments

Hello dear developers.

What happened?
I'm trying to use Uuid structure for wasm-bindgen, but I get compiler errors.
image

Steps to reproduce the behavior:

use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct Foo(pub uuid::Uuid);

What were you expecting?
No compiler error from building it with: wasm-pack build --target nodejs

What's the context?

  • Target: wasm32-unknow-unknow, rust version rustc 1.66.0-beta.2 (0040709e3 2022-11-20)
wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] }
uuid = { version = "1.2.2", features = ["v4", "js", "serde", "wasm-bindgen"] }

Hi @barvirm 👋

I’m not sure there’s a native wasm type that a UUID would naturally map to. You should be able to marshal them as byte slices and convert between UUIDs.

If it is expected that libraries implement this trait on types they define though then we can look at what an appropriate implementation would look like.

Just coming in through some triage. There hasn't been any activity here for a while. Since there's no native type to directly map a UUID to, I don't think there's anything for us to do here. Callers should pick an appropriate string/binary representation for their use-case.