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

How can I serialize an alloc::string::String or alloc::vec::Vec in no_std environment? #2070

Closed
wangtianxia-sjtu opened this issue Aug 10, 2021 · 1 comment
Labels

Comments

@wangtianxia-sjtu
Copy link

How can I serialize an alloc::string::String or alloc::vec::Vec in no_std environment?
I have been using these two data structures in a no_std rust project, but I have encountered a problem that #[derive(Serialize, Deserialize)] cannot generate the proper function

#[derive(Serialize, Deserialize)]
pub(crate) struct Test {
    pub(crate) test: String, // this is alloc::string::String in no_std environment
}
error[E0277]: the trait bound `String: Serialize` is not satisfied
  --> src/image/mod.rs:36:5
   |
36 |     pub(crate) test: String,
   |     ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Serialize` is not implemented for `String`
   |
   = note: required by `image::_::_serde::ser::SerializeStruct::serialize_field`

error[E0277]: the trait bound `String: Deserialize<'_>` is not satisfied
  --> src/image/mod.rs:36:5
   |
36 |     pub(crate) test: String,
   |     ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `String`
   |
   = note: required by `next_element`

error[E0277]: the trait bound `String: Deserialize<'_>` is not satisfied
  --> src/image/mod.rs:36:5
   |
36 |     pub(crate) test: String,
   |     ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `String`
   |
   = note: required by `next_value`
@dtolnay
Copy link
Member

dtolnay commented Jan 23, 2022

Please take this question to one of the resources listed in https://github.com/serde-rs/serde/tree/v1.0.135#getting-help. Sorry that no one was able to provide guidance here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants