-
Notifications
You must be signed in to change notification settings - Fork 98
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
Addressing ergonomics around Rust and embedded/no_std development #26
Comments
@Susurrus Thanks for the write up! Some comments
|
These are on point. I've run up against many of the same places of friction. |
I have a question about Small example:
As you can see, I didn't have to do any real changes to If I had some easy way to provide a custom |
@pftbest instead of writing custom IO traits, please consider using |
@Kixunil If I understand correctly, I did consider using |
Thank you for feedback! I'm considering to implement byteorder-like trait for |
Maybe it would be better to add |
@pftbest Since I looked at |
@pftbest are you interested in posting your fork of rmp on crates.io? I need pretty much the exact same thing. I've been unable to find an existing rust library on crates.io that supports a "robust" serialization format (meaning contains the description of the data schema as well as the bytes) e.g. messagepack, CBOR, avro, and supports There is |
@cbeck88 Sorry, I've missed your message. I don't think I will post post my fork on crates.io, mainly because it is low quality hack. For example I've defined my own io::Read and io::Write traits, and implemented them only for arrayvec and arraystring, so if you want to use them with some other containers you'll have to modify the source code which is not possible with crates.io. Also there is a hard limit on string length of 512 bytes, because I don't use allocations, and have to create strings on the stack. You might want to change this number for your project. If you still want to see the code you can download it here: |
@pftbest Hey, I did some work to update your patch. I agree it's not the prettiest but it's really the best option right now at least for us. You can see our updated version of your patch here: 3Hren/msgpack-rust#187 I didn't fully understand what is needed for byteorder -- We're interested in investing time and energy in this to make this as maintainable as possible. Thanks for making your patch available. |
@cbeck88, byteorder is needed because of how rmp works internally. It is using functions like P.S. I completely forgot that I had this code on github, I thought I only had a local copy. Thanks for finding it. |
Sorry for replying this late, yes, it does work, you just need to enable |
Closing this as part of the 2024 triage effort, as I believe quite a few of these have either been addressed, or are captured in the embedded rust book, or are encoded in other general best practices. If anyone disagrees with this and would like it reopened, please let me know and we can discuss it in the next weekly meeting onMatrix. |
thank you for anyone who follows this issue in the future, in the project we were working on, we ended up using prost , which has moved from danburkert to the tokio-rs umbrella. https://github.com/tokio-rs/prost at the time I made a PR that introduced no_std + alloc support: tokio-rs/prost#215 I highly recommend that library, it's great |
This issue is a place to track broadening the Rust embedded ecosystem by tracking various papercuts that will hit users, especially new ones (both to embedded and Rust), when they start to dive it. Rust has been good at attracting new users and many don't come with a systems background. The broad availability of SBCs and microcontrollers that Rust can target and can be used for cool hobbyist or IoT projects will likely pull in many new users to the embedded development side of Rust. We should coddle these users into full-fledged embedded devs and increase our numbers!
Anyways, on to the list:
no_std
version with less functionality and astd
version is to have a feature and enable it by default. We should decide on a consistent name and get this written up as a convention somewhere for devs to reference (tracked here). Once that's finished we could also scan crates.io for crates that use other names and file tickets against them to encourage the ecosystem to standardize [NO TRACKING ISSUES]std
by default) do not havecore
available to them and have to explicitly import them viaextern crate core
. Additionally, when compiling asno_std
, this then results in a compilation error. This combination increases the friction for a user trying to use justcore
instead ofstd
where possible. I suggest thatcore
be automatically included for all projects (except if#![no_core]
is specified). [NO TRACKING ISSUES]std
version of something because of how the docs are arranged. Knowing aboutcore
and caring aboutno_std
use is almost always not a primary thought of the crate developer. Convincing them to supportno_std
is now more onerous as they have to go in and adjust all the use paths to core. This is especially problematic given the point above. It would be great if this could be ameliorated by#![no_std]
automatically mapping thosestd
paths tocore
. A partial solution could be injectinguse core as std
. [NO TRACKING ISSUES]no_std
crates, including hybrid dependencies (mixedstd
/no_std
) doesn't expose only theno_std
functionality by default. As discussed in Point 1 here many imports then look likebyteorder = { version = "1", default-features = false }
. So for users coming fromstd
, there's extra work even declaring crate dependencies. [NO TRACKING ISSUES]signum()
,sqrt()
, and the like. It's a big surprise to users that they can't usesqrt()
without the standard library! Other proposed functionality isOsStr
andPathBuf
and some of the UTF-16 processing, though for the first two it's a little unclear how those might be implemented. There are likely others and an audit ofstd
would likely be enlightening. [tracking issue 1, tracking issue 2]no_std
even if they could.ref_slice
is one such example where the author wasn't aware til an issue was posted. There's likely some work here that can be done to alert crate authors, though the most appropriate time seems to be when publishing to crates.io or when usingclippy
[tracking issue]no_std
just specifies that the crate code doesn't need it, but std could still be pulled in by a dependency. This combos with Point 4 to make it the default that a user could try to implement ano_std
crate and ship it only to have downstream users complain that it's notno_std
because he forgot to include a dependency properly. There should be some sort of compilation check for this (it's part of The Rust Way(TM)). Maybe a clippy lint here would be a good place to start. [NO TRACKING ISSUES]cargo checklist
command that could be helpful here for new crate authors (tracking issue).no_std
. This is a combination of exposure and the niche ofno_std
developers. Increasing users' exposure tono_std
crates so they a) know they're available and b) think about making their crates suportno_std
could be a good way to start here. I've suggested a badge on crates.io for no_std-compatible crates] to compliment theno_std
keyword andno_std
categories that are already there. Everyone loves badges!cargo test
by default doesn't exposestd
forno_std
crates. This makes it harder to debug and work with tests for users used to doingprintln!()
. I believestd
should still be exposed within the test code itself, but it might also be worth compiling the crate asstd
so that these debugging statements can be inserted. This should only apply to the crate itself and not upstream dependencies. [NO TRACKING ISSUES].The text was updated successfully, but these errors were encountered: