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

Possible no_std support #5

Open
xxuejie opened this issue Sep 6, 2023 · 3 comments
Open

Possible no_std support #5

xxuejie opened this issue Sep 6, 2023 · 3 comments

Comments

@xxuejie
Copy link

xxuejie commented Sep 6, 2023

Hi there,

I was trying to use bcs in an environment without std support, after some hacking, I've put together a commit that compiles in a no_std environment: xxuejie@7e6b1f3 Some of my changes include:

  • Switch from std to core for components that exist in both crates, such as core::result::Result
  • Use Vec and String from alloc instead of std
  • Add a just-enough io module in no_std environment to minimize changes to existing logic
  • (Perhaps the most controversial one), I have to use onlyerror, which is like thiserror but works in no_std environment. And for this to work I have to switch to a nightly version of Rust, since core::error::Error is not stable yet. An alternative path is what postcard does now, but we lose the custom message

So my question here is: is no_std support that you would consider to be accepted to upstream? And if so, how do you suggest we deal with the thiserror issue?

Thanks!

@ma2bd
Copy link
Contributor

ma2bd commented Oct 8, 2023

Hi @xxuejie, Thanks for reaching out! I don't think we want to switch to the nightly Rust. I'm open to the idea of a feature std that would activated by default but can be removed to activate your suggestions.

@bmwill What do you think?

@xxuejie
Copy link
Author

xxuejie commented Oct 18, 2023

Hey thanks for the reply! I could prepare a PR that adds std as a default-on feature, so the messages defined on errors will only be available when std feature is enabled. Rest of changes are just as described above. This will make sure stable Rust can be used, will that work for your case?

@ma2bd
Copy link
Contributor

ma2bd commented Apr 19, 2024

Sounds good to me

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