I'm using Rocket and I'm trying to create a Layout
struct. I've implemented serde::Serialize
, because the documentation says the static method Template::render
's second argument accepts a struct that implements Serialize
:
struct Layout {
data: String,
second: String,
}
impl Layout {
fn new(data: String, second: String) -> Layout {
Layout { data, second }
}
fn render(&self) -> Template {
Template::render("Layout", &self)
}
}
impl Serialize for Layout {
fn serialize<S>(&self, serialize: S) -> Result<S::Ok, S::Error>
where S: Serializer
{
let mut state = serializer.serialize_struct("Layout", 2);
state.serialize_field("data", &self.data)?;
state.serialize_field("second", &self.data)?;
state.end()
}
}
I get the error
the trait `serde::ser::Serialize` is not implemented for `layout::Layout`
What did I do wrong?