use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
pub struct Monitor {
/* A few field */
#[serde(skip)]
pub thread_wrapper: Option<ThreadWrapper>
}
But then I receive the error message "cannot find attribute serde in this scope" when I try to compile my program. Any idea on how to solve that ?
That's not the problem, I want serde to skip serealization on that field because that struct is field is NOT serializable. And again, the error is not about unimplemented traits.
EDIT : if you meant on the "parent" struct, I did add #[derive(Serialize, Deserialize)], I just didn't include it
Make sure you're using a recent version of serde (run cargo update). Also, you need to have the derive feature of serde enabled, if you don't, you should also have an error for "unrecognized derive".
If you don't have an "unrecognized derive" error, are running a recent version of serde_derive, and have the "unrecognized attribute serde" error, then you don't have the derive attribute on that struct.
[dependencies]
rocket = "0.4.5"
serde = { version = "1.0.115", features = ["derive"] }
lazy_static = "1.4.0"
serde_json = "1.0.57"
[dependencies.rocket_contrib]
version = "0.4.5"
default-features = false
features = ["tera_templates", "serve", "json"]
They are all updated, and I do have #[derive(Serialize, Deserialize)] on the struct.
As you can see, there's no serde_derive in my dependencies, but I though the derive feature would suffice