Skip to content
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

wasm support? #8

Open
zhangzqs opened this issue May 19, 2024 · 4 comments
Open

wasm support? #8

zhangzqs opened this issue May 19, 2024 · 4 comments

Comments

@zhangzqs
Copy link
Contributor

zhangzqs commented May 19, 2024

Is it possible to port it to run on the wasm platform?
wasm in browser don't support Instant::now().
If this interface is defined, it will be able to run on the wasm platform
#2 (comment)

@maxwase
Copy link
Owner

maxwase commented May 19, 2024

That's an interesting question, I didn't consider WASM as a platform for this crate, however it seems that it is possible, so why not 😄

As you have already spotted, there is an issue for an external timer trait, honestly, I don't have good ideas on how to define one straight away, however I didn't think about it much. This issue is kind of the same to the one in embedded_hal crate, they also struggle to define one generic enough trait...

Could you please share an example on how you would like to use this crate on WASM platform and how you would implement Instant on it if it misses one? That would help to consider needed aspects for the trait.

@zhangzqs
Copy link
Contributor Author

That's an interesting question, I didn't consider WASM as a platform for this crate, however it seems that it is possible, so why not 😄

As you have already spotted, there is an issue for an external timer trait, honestly, I don't have good ideas on how to define one straight away, however I didn't think about it much.

Could you please share an example on how you would like to use this crate on WASM platform and how you would implement Instant on it if it misses one? That would help to consider needed aspects for the trait.

Actually, we don't rely on absolute time, we only need to rely on the relative time since the Button was new, so we can actually just use core::time::Duration instead of Instant.

@zhangzqs
Copy link
Contributor Author

zhangzqs commented May 19, 2024

I tried to file a draft PR to change this, but noticed that the State enum and raw_state function are public, which means some incompatible changes have occurred to the public API.

https://github.com/maxwase/button-driver/pull/9/files

@maxwase
Copy link
Owner

maxwase commented May 20, 2024

It would be great if you could try to implement your use case using #10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants