I am trying to take some json that looks like this:
{
"foo": "bar",
"name": "some name"
}
and use serde to deserialize it to a data structure like this:
#[derive(Clone, PartialEq, Debug)]
pub struct Quux {
foo: Foo,
name: String,
}
pub enum Foo {
Bar,
Baz,
}
I have some code, but to be honest, it is pretty much straight out of the serde guide to "deserializing without macros," and I'm not sure exactly what I would need to do to get it to deserialize the foo field to a Foo.
I have implemented Deserialize for the Foo enum, which I thought would be enough for the visitor.visit_value() call in my impl serde::de::Vistor for QuuxVisitor to call that version of deserialize, but does not seem to be the case.
The error I get when I try to deserialize to Quux is called 'Result::unwrap()' on an 'Err' value: SyntaxError("expected value", 2, 20), but if I change Quux to use a String for foo instead of a Foo, it deserializes fine.