Upgrade to serde 1.0
serde 1.0.0 introduces breaking changes. See the release notes for more details: <https://github.com/serde-rs/serde/releases/tag/v1.0.0>. Fixes #50
This commit is contained in:
parent
032b03add3
commit
0f5182460f
2 changed files with 21 additions and 12 deletions
|
@ -24,7 +24,7 @@ expose-test-schema = []
|
|||
[dependencies]
|
||||
rustc-serialize = { version = "^0.3.19", optional = true }
|
||||
iron = { version = "^0.5.1", optional = true }
|
||||
serde = { version = "^0.9.1", optional = true }
|
||||
serde = { version = "^1.0.8", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
iron = "^0.5.1"
|
||||
|
|
|
@ -49,13 +49,13 @@ impl<'a> ser::Serialize for GraphQLError<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl de::Deserialize for InputValue {
|
||||
impl<'de> de::Deserialize<'de> for InputValue {
|
||||
fn deserialize<D>(deserializer: D) -> Result<InputValue, D::Error>
|
||||
where D: de::Deserializer,
|
||||
where D: de::Deserializer<'de>,
|
||||
{
|
||||
struct InputValueVisitor;
|
||||
|
||||
impl de::Visitor for InputValueVisitor {
|
||||
impl<'de> de::Visitor<'de> for InputValueVisitor {
|
||||
type Value = InputValue;
|
||||
|
||||
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
|
||||
|
@ -98,23 +98,32 @@ impl de::Deserialize for InputValue {
|
|||
Ok(InputValue::null())
|
||||
}
|
||||
|
||||
fn visit_seq<V>(self, visitor: V) -> Result<InputValue, V::Error>
|
||||
where V: de::SeqVisitor,
|
||||
fn visit_seq<V>(self, mut visitor: V) -> Result<InputValue, V::Error>
|
||||
where V: de::SeqAccess<'de>,
|
||||
{
|
||||
let values = try!(de::impls::VecVisitor::new().visit_seq(visitor));
|
||||
let mut values = Vec::new();
|
||||
|
||||
while let Some(el) = try!(visitor.next_element()) {
|
||||
values.push(el);
|
||||
}
|
||||
|
||||
Ok(InputValue::list(values))
|
||||
}
|
||||
|
||||
fn visit_map<V>(self, visitor: V) -> Result<InputValue, V::Error>
|
||||
where V: de::MapVisitor,
|
||||
fn visit_map<V>(self, mut visitor: V) -> Result<InputValue, V::Error>
|
||||
where V: de::MapAccess<'de>,
|
||||
{
|
||||
let values = try!(de::impls::HashMapVisitor::<String, InputValue, _>::new()
|
||||
.visit_map(visitor));
|
||||
let mut values: HashMap<String, InputValue> = HashMap::new();
|
||||
|
||||
while let Some((key, value)) = try!(visitor.next_entry()) {
|
||||
values.insert(key, value);
|
||||
}
|
||||
|
||||
Ok(InputValue::object(values))
|
||||
}
|
||||
}
|
||||
|
||||
deserializer.deserialize(InputValueVisitor)
|
||||
deserializer.deserialize_any(InputValueVisitor)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue