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

Make api/rpc interfaces no_std compatible #384

Merged
merged 2 commits into from
Dec 20, 2022

Conversation

haerdib
Copy link
Contributor

@haerdib haerdib commented Dec 19, 2022

One step further towards no_std compatibility:

  • compsoe-macros is now fully no_std compatible
  • api/rpc is now fully no_std compatible
  • remove unused primitives-types import in Cargo.toml

Drawbacks:

  • thiserror needed to be changed to thiserror-core. But that should be temporary only. And better than removing it completely (I hope).
  • Some errors needed to be changed from Error-Types to Strings, because they are not available in no_std.

one step towards #279

@haerdib haerdib self-assigned this Dec 19, 2022
@@ -15,11 +15,7 @@

*/

#[cfg(not(feature = "std"))]
Copy link
Contributor Author

@haerdib haerdib Dec 19, 2022

Choose a reason for hiding this comment

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

std::string::String points to alloc::string::String as well. So I removed this obsolete condition completely.

@haerdib haerdib changed the title Make rpc interface no-std compatible Make api/rpc interfaces no_std compatible Dec 19, 2022
@haerdib haerdib marked this pull request as ready for review December 19, 2022 13:49
Copy link
Contributor

@echevrier echevrier left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@clangenb clangenb left a comment

Choose a reason for hiding this comment

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

Nice looks good!

Just remember, if IoT should be one of the target deployments of this, we might want to get rid of thisError in no_std whatsoever, at least for production builds. The footprint of the error-chain that errors contain is not negligible.

Comment on lines 147 to 152
#[cfg(not(feature = "std"))]
/// Insert a plain value into the builder with heap allocation. If available,
/// use the more efficient std version.
pub(crate) fn insert<P: Serialize>(&mut self, value: P) -> Result<()> {
self.insert_with_allocation(value)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Usually the doc is above the feature flag

@haerdib
Copy link
Contributor Author

haerdib commented Dec 20, 2022

Good point. But maybe a full cleanup would be sensible, as propagating Strings is also not very efficient, I suppose. I commented in #317 accordingly.

Copy link
Collaborator

@clangenb clangenb left a comment

Choose a reason for hiding this comment

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

LGTM!

@haerdib haerdib merged commit add60a5 into master Dec 20, 2022
@haerdib haerdib deleted the bh/make-rpc-interface-no-std-compatible branch December 20, 2022 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants