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

Deriving some common traits + defmt feature and no_std support #2

Closed
3 tasks done
elpiel opened this issue Nov 15, 2024 · 4 comments
Closed
3 tasks done

Deriving some common traits + defmt feature and no_std support #2

elpiel opened this issue Nov 15, 2024 · 4 comments

Comments

@elpiel
Copy link

elpiel commented Nov 15, 2024

  • In addition to the current Debug derive of IbusPacket and ParsingError it would be nice to have Clone/Copy and defmt::Format (enabled with a features as an optional dep.) to be used in no_std environment.

  • To support no_std we can use core::error::Error (which is stable since 1.81) so either a MSRV should be added or std::error::Error impl should be enabled only with a feature, e.g. std feature.

  • core::fmt::Display can be used instead of the std::fmt::Display to support no_std

@elpiel elpiel changed the title Deriving some common traits + defmt feature and support no_std Deriving some common traits + defmt feature and no_std support Nov 15, 2024
@mariano-f-r
Copy link
Owner

I will definitely try to migrate the traits provided by std to core, as that is an easy fix. As to why I never did it sooner, I built this for a drone with a flight controller running in a Raspberry Pi 4's userland.

As to the dependencies, I've never actually written a crate with feature flags, although I imagine it is not difficult.

I will begin working on this once my studies become less difficult.

@elpiel
Copy link
Author

elpiel commented Nov 19, 2024

That's great! Good luck with your studies.
I can also open a PR, however, it might be a good opportunity for you to exercise adding features to crates.

Do let me know if you need some assistance.
PS: You can also check e.g. our nmea crate as it adds conditions derives to structures based on feature flags: https://github.com/AeroRust/nmea/

@mariano-f-r
Copy link
Owner

Done.

Core traits added with 4e985e5
Copy and clone were added with 09bbdc4
and defmt support was added with 3aafa0b

Unfortunately due to not being able to enable features for tests (which is currently being discussed here), I could not verify the functionality of the defmt feature working. Given how simple the derive was, I imagine it works fine.

@elpiel
Copy link
Author

elpiel commented Nov 24, 2024

Yaay! Btw for MSRV you can add "rust-version" to Cargo.toml

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