Skip to content

Add no_std support#158

Merged
tafia merged 33 commits into
tafia:masterfrom
jpopesculian:no_std
May 17, 2020
Merged

Add no_std support#158
tafia merged 33 commits into
tafia:masterfrom
jpopesculian:no_std

Conversation

@jpopesculian

Copy link
Copy Markdown
Contributor

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

mullr and others added 30 commits September 9, 2019 15:07
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
@jpopesculian jpopesculian requested review from nerdrew and tafia January 24, 2020 17:04
@jpopesculian

Copy link
Copy Markdown
Contributor Author

@nerdrew @tafia what's the status on this?

@tafia tafia left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread pb-rs/src/types.rs
}
FieldType::Map(ref key, ref value) => format!(
"HashMap<{}, {}>",
"KVMap<{}, {}>",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread pb-rs/src/types.rs
}
FieldType::Map(ref key, ref value) => format!(
"HashMap<{}, {}>",
"KVMap<{}, {}>",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"KVMap<{}, {}>",
"{}<{}, {}>",
if config.no_std { "KVMap" } else { "HashMap" },

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

@therealprof

Copy link
Copy Markdown
Contributor

Can we please get this merged some time? 😅

@tafia tafia left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

@tafia

tafia commented May 17, 2020

Copy link
Copy Markdown
Owner

Sorry for the very long delay. Merging it once the CI tests pass.
Will deploy a new version just after

@tafia tafia merged commit 5325627 into tafia:master May 17, 2020
@therealprof therealprof mentioned this pull request May 17, 2020
@tafia

tafia commented May 17, 2020

Copy link
Copy Markdown
Owner

Deployed v0.9.0 of pb-rs

@therealprof

Copy link
Copy Markdown
Contributor

Causes #165

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

Successfully merging this pull request may close these issues.

5 participants