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

sync api #1

Open
patrickelectric opened this issue Nov 28, 2024 · 2 comments · May be fixed by #2
Open

sync api #1

patrickelectric opened this issue Nov 28, 2024 · 2 comments · May be fixed by #2
Labels
enhancement New feature or request

Comments

@patrickelectric
Copy link

Nice library! It would be possible to have a sync API ?
I'm trying to use it with linux_embedded_hal

@asasine
Copy link
Owner

asasine commented Dec 1, 2024

Hello and welcome! Are you familiar with APIs for sharing implementations between sync and async? I'd like to reuse tests and impls where possible to avoid duplication.

@asasine asasine added the enhancement New feature or request label Dec 1, 2024
@asasine asasine linked a pull request Dec 8, 2024 that will close this issue
@asasine
Copy link
Owner

asasine commented Dec 19, 2024

Taking a deeper look at the problem here, which boils down to me wanting to reuse the async implementation in any sync APIs, makes me realize there's no good way to do this currently. There's an initiative to make this possible, but I suspect it's not coming to stable Rust soon.

One alternative is to have callers use something like async_std::task::block_on. Have you tried something like this with linux-embedded-hal?

There's also the possibility to add async support into linux-embedded-hal for this crate's needed APIs. There's precedence there with the async DelayNs being supported in rust-embedded/linux-embedded-hal#109, though this only targets the tokio runtime. Is there a chance you'd be able to use an async runtime on Linux in your project?

In the meantime, I'll take a closer look at your PR. Some repeated implementations on a small crate like this isn't the end of the world.

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

Successfully merging a pull request may close this issue.

2 participants