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

Lift the alloc requirement from most of the traits #15

Closed
ivmarkov opened this issue May 11, 2022 · 3 comments
Closed

Lift the alloc requirement from most of the traits #15

ivmarkov opened this issue May 11, 2022 · 3 comments

Comments

@ivmarkov
Copy link
Collaborator

ivmarkov commented May 11, 2022

Currently, a lot of traits do require alloc. However and at a closer inspection, often this requirement is just for convenience features, like Cow (mqtt client traits), or incidental usage of String (wifi trait configuration) which can be avoided either by using heapless (as the strings have an upper limit) or better yet - lifetimed &str.

Given that it might be very possible to provide completely alloc-free implementations of these traits (or at least of their asyncified versions), we should remove the alloc requirements from these traits.

@ivmarkov
Copy link
Collaborator Author

Also important given that support for Embassy on the esp32* chips is picking up steam.

@ivmarkov
Copy link
Collaborator Author

ivmarkov commented Jun 1, 2022

Progress on this here.

@ivmarkov
Copy link
Collaborator Author

Done:

  • All errors demoted to either Error: Debug, or to the error from the embedded-io traits, which is now a hard dependency. Note that this WILL result in harder to use traits especially for folks who are used to into()-ing errors into anyhow::Error and then propagating up the call stack chain without any error inspection. This used to be possible before when all traits used to return an error trait which was Send + Sync + 'static so it was into()-able to anyhow::Error, but this is no longer the case
  • Module io now re-exports the sync and async traits from embedded-io
  • All String, Vec and Cow usages are replaced either with simple slices and &str references, or with heapless::String & heapless::Vec, depending on the context and the ease of use. heapless is now a hard dependency as well, but is used in a handful of structures
  • The experimental http::server traits are significantly simplified. They no longer have the old style APIs which returned a Response, as this pattern cannot be implemented without alloc
  • All asyncs modules renamed to asynch, to match the same naming convention in embedded-io

What is kind of important now is to validate the no-alloc async traits specifically (the various asynch modules). We should probably start with the HTTP client traits and (to some extent) the MQTT client, followed by the OTA traits.

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

1 participant