Add no_std support#158
Conversation
This replaces all public uses of the Writer trait with the new WriterBackend, which defines only the interaction points which are actually used. It also introduces the BytesWriter struct as a new implementation of WriterBackend that will work in no_std, along with the serialize_into_slice convenience fn. This is technically a breaking change, as it will require stubs to be regenerated.
- Add the `std` feature to the quick-protobuf runtime crate - Put uses of Vec and std::io::Write behind the `std` feature - Change other uses of `std` to `core` - Add the `quick-protobuf/no-std-example` compile test
…nostd mode; regenerate nostd test proto
tafia
left a comment
There was a problem hiding this comment.
Thanks a lot for this PR, I really like it.
I have one small comment about KVMap which I'd like to be removed if possible.
Sorry for the super long delay before the review!
| } | ||
| FieldType::Map(ref key, ref value) => format!( | ||
| "HashMap<{}, {}>", | ||
| "KVMap<{}, {}>", |
There was a problem hiding this comment.
I believe most people won't use no_std and they'd rather use regular std::HashMap.
I understand that the distinction is done at import time but I'd like things to be as simple as possible for std users.
| } | ||
| FieldType::Map(ref key, ref value) => format!( | ||
| "HashMap<{}, {}>", | ||
| "KVMap<{}, {}>", |
There was a problem hiding this comment.
| "KVMap<{}, {}>", | |
| "{}<{}, {}>", | |
| if config.no_std { "KVMap" } else { "HashMap" }, |
There was a problem hiding this comment.
Hey @tafia, sorry for the delay in the reply! Thanks for taking a look 😄 I added the KVMap because the rust_type function doesn't have access to the config object (and I didn't want to change the call definition for a bunch of function), and the alias shouldn't restrict with what the actual person uses (other than reflecting in the docs). Obviously, I'd be happy to change it if you want, but I wanted to check with you first. I could of course also alias BTreeMap to HashMap but that seems a little hacky...
There was a problem hiding this comment.
I checked, the alias, actually does not reflect in the docs because its private. It's really pretty invisible to the user of the struct...
|
Can we please get this merged some time? 😅 |
|
Sorry for the very long delay. Merging it once the CI tests pass. |
|
Deployed v0.9.0 of pb-rs |
|
Causes #165 |
Haha let's try this a 3rd time... Building off of @xoloki's #148 work, I'd like to get this finalized and merged in. Let me know what you guys need to get this done