Compilation error with wasm_bindgen #653

Closed
opened 2023-01-18 10:30:30 -06:00 by barvirm · 2 comments
barvirm commented 2023-01-18 10:30:30 -06:00 (Migrated from github.com)

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"] }
Hello dear developers. **What happened?** I'm trying to use Uuid structure for wasm-bindgen, but I get compiler errors. ![image](https://user-images.githubusercontent.com/15948420/213251217-b4034f0f-4f02-4aa9-98ec-7ebf14376e2c.png) Steps to reproduce the behavior: ``` rust 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) ```toml wasm-bindgen = { version = "0.2.83", features = ["serde-serialize"] } uuid = { version = "1.2.2", features = ["v4", "js", "serde", "wasm-bindgen"] } ```
KodrAus commented 2023-01-30 23:12:33 -06:00 (Migrated from github.com)

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.

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.
KodrAus commented 2023-05-06 04:10:39 -05:00 (Migrated from github.com)

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.

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.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-uuid-rs/uuid#653
No description provided.