wasm-bindgen icon indicating copy to clipboard operation
wasm-bindgen copied to clipboard

distinguish between `MediaStreamTrack` clone, and rust Clone::clone

Open deep-gaurav opened this issue 1 year ago • 3 comments

Motivation

So I was working with WebRTC Media Stream Track and was cloning with with .clone() thinking it'll do shallow clone just like how all other web-sys api does shallow clone, but MediaStreamTrack has a clone method in js too that does deep clone which is what is invoked here. It becomes very hard to debug unless you know this. maybe we can mark it somehow?

Proposed Solution

Not exactly sure what can be done but maybe rename deep clone?

Alternatives

We can also just do some linting for it?

Additional Context

NA

deep-gaurav avatar Oct 11 '24 13:10 deep-gaurav

This could be easily added to the list of Rust keywords, but unfortunately it requires much more plumbing to generate duplicate methods to avoid a breaking change.

I'm happy to look over a PR, which can also deprecate the old methods.

daxpedda avatar Oct 12 '24 19:10 daxpedda

Unfortunately I dont think I've enough knowledge of how web-sys/wasm_bindgen works internally to make PR. If you can point me somewhere to getstarted on learning it, I would be willing to look into it.

deep-gaurav avatar Oct 14 '24 08:10 deep-gaurav

If you can point me somewhere to getstarted on learning it, I would be willing to look into it.

I don't think we have any documentation on the internal code architecture that would help with this. To get started you would just have to dig into the code.

daxpedda avatar Oct 14 '24 09:10 daxpedda