-
Notifications
You must be signed in to change notification settings - Fork 626
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
no_std support for futures-io #860
Comments
And finally got round to using this on some real hardware, it works perfectly (although, integrating task notification into HAL layers without impacting non- |
Thanks @Nemo157 for taking on this work! I strongly agree with your overall goals. I'd really like to see if we can somehow finagle |
Is there any blockers on this? I really wish there is some Also since 0.3 picks up some nightly features ( |
It would be really awesome if you could somehow write your embedded code as async functions, and then have some clever executor setup the necessary interrupts and call |
I don't believe this is something we'll be able to tackle without support from upstream, since I think it's important that these traits mirror the upstream |
@cramertj Not everything can be implemented for no_std for io, but most of it can now thanks to https://github.com/jethrogb/rust-core_io. |
Inspired by @Ericson2314's comment on a portability-wg issue about allocation-less
std::io::Error
I decided to attempt a two-layered approach toAsync{Read,Write}
allowing supportingno_std
targets with most of thefutures-io
andfutures-util::io
adaptors.The main change required is a second set of traits (
CoreAsync{Read,Write}
) which have an associated error type instead of usingstd::io::Error
, theAsync{Read,Write}
traits are then implemented on top of these traits whereCoreAsync{Read,Write}::Error: Into<std::io::Error>
.One difficulty is that some of the more important adaptors (e.g.
futures-util::io::ReadExact
) re-use error variants fromstd::io::Error
, my first attempt at working around this limitation is to force the underlying error type to provide at least the two variants that the adaptors require. This seems a bit messy, I'm unsure if there's a much nicer solution to this.My main goal with this was to be able to use these adaptors with types from the
embedded-hal
library for non-blocking serial connections, via thenb
library. I have an example of this compiling now, but I'll have to wait till I'm at work tomorrow to try and get it running on real hardware.Links to the changes:
futures
changesnb
changesembedded-hal
changesI'm creating this issue now to get feedback on whether this is something that might be supported by the core
futures
library at some point. I really would like to avoid splitting the ecosystem betweenstd
andno_std
Futures, e.g. I'm likely to be looking at using/building a non-blocking CoAP library, and am hoping to be able to make it work with bothstd
andno_std
environments without much effort in the library itself.The text was updated successfully, but these errors were encountered: