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

no_std support? #189

Closed
vitiral opened this issue Jun 5, 2017 · 14 comments
Closed

no_std support? #189

vitiral opened this issue Jun 5, 2017 · 14 comments

Comments

@vitiral
Copy link

@vitiral vitiral commented Jun 5, 2017

I didn't see no_std support in the documentation / cargo.toml / issues so I thought I would open one. This library seems perfect for no_std serialization in microcontrollers. What are the biggest barriers to supporting no_std? Would you welcome a PR that did so?

Thanks!

@dtolnay
Copy link
Collaborator

@dtolnay dtolnay commented Jun 5, 2017

Yes! I don't know what the biggest barriers are but we would love a PR to support no_std.

@vitiral
Copy link
Author

@vitiral vitiral commented Jun 5, 2017

A rough design could be:

  • have std feature for current functionality, and default-features = false mean no_std
  • when not feature=std:
    • don't use anything from the io or collections/vecmodules (std only), instead use array references like the byteorder crate
    • errors/expect/etc shouldn't use strings (or use very short ones) to stay as memory efficient as possible.
  • use default-features = false on serde along with the conditional cargo feature (rust-lang/cargo#633)

Theoretically I hope that's it! Not a small amount of work, but hopefully doable

@vitiral
Copy link
Author

@vitiral vitiral commented Jun 5, 2017

I'm going to try and give this a shot this week

@vitiral
Copy link
Author

@vitiral vitiral commented Jun 5, 2017

It looks like we depend on rust-num/num#296, which is an open PR that will hopefully be done soonish!

@vks
Copy link

@vks vks commented Jun 9, 2017

rust-num/num#296 has been merged, num-traits 0.1.38 can be build without std.

@vitiral
Copy link
Author

@vitiral vitiral commented Jun 10, 2017

I took an initial stab at this and it is way more difficult than I first anticipated.

Also, ssmarshall does pretty much everything I needed

https://crates.io/crates/ssmarshal

Not sure where this issue should go, but I won't be working on it!

@vitiral
Copy link
Author

@vitiral vitiral commented Jun 10, 2017

Thus crate could be no_std, but it would basically be ssmarshall with u32 enum variants and configurable byte ordering

@TyOverby
Copy link
Collaborator

@TyOverby TyOverby commented Jun 11, 2017

Yeah... bincode is pretty dependent on std::io::Write and std::io::Read which isn't no_std compatible.

@TyOverby TyOverby closed this Jun 11, 2017
@astraw
Copy link

@astraw astraw commented Jul 2, 2017

core_io's documentation says that it provides the Read and Write traits for use with core and does not require std. I have not tried it myself.

@vlad9486
Copy link

@vlad9486 vlad9486 commented Sep 17, 2018

Take a look on my crate tirse. I just committed, the work still in progress.

@noonien
Copy link

@noonien noonien commented May 6, 2020

Any update on this?

@vks
Copy link

@vks vks commented May 6, 2020

I think no_std support is not intended for bincode. Such support would likely require significant limitations, see the ssmarshall crate, which is essentially a reimagination of bincode for no_std applications.

@noonien
Copy link

@noonien noonien commented May 6, 2020

The no_std story has really changed since 2 years ago. It's a lot easier to provide no_std support nowadays.

@vitiral
Copy link
Author

@vitiral vitiral commented May 6, 2020

some context: there IS a protobuf implementation (in C) for micro-controllers:
https://github.com/nanopb/nanopb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.