Update serde 0.7.0

This commit is contained in:
Curtis McEnroe 2016-02-27 14:39:43 -05:00
parent 0e9cb14231
commit 6187798a24
4 changed files with 17 additions and 17 deletions

View File

@ -16,9 +16,9 @@ readme = "README.md"
chrono = "0.2.17"
hyper = "0.7.0"
rustc-serialize = "0.3.16"
serde = "0.6.1"
serde = "0.7.0"
url = "0.5.0"
[dev-dependencies]
serde_json = "0.6.0"
serde_json = "0.7.0"
yup-hyper-mock = "1.3.2"

View File

@ -64,7 +64,7 @@ impl<L: Lifetime> FromResponse for Bearer<L> {
impl<L: Lifetime + Serialize> Serialize for Bearer<L> {
fn serialize<S: Serializer>(&self, serializer: &mut S) -> Result<(), S::Error> {
serializer.visit_struct("Bearer", SerVisitor(self, 0))
serializer.serialize_struct("Bearer", SerVisitor(self, 0))
}
}
@ -73,9 +73,9 @@ impl<'a, L: Lifetime + Serialize + 'a> ser::MapVisitor for SerVisitor<'a, L> {
fn visit<S: Serializer>(&mut self, serializer: &mut S) -> Result<Option<()>, S::Error> {
self.1 += 1;
match self.1 {
1 => serializer.visit_struct_elt("access_token", &self.0.access_token).map(Some),
2 => serializer.visit_struct_elt("scope", &self.0.scope).map(Some),
3 => serializer.visit_struct_elt("lifetime", &self.0.lifetime).map(Some),
1 => serializer.serialize_struct_elt("access_token", &self.0.access_token).map(Some),
2 => serializer.serialize_struct_elt("scope", &self.0.scope).map(Some),
3 => serializer.serialize_struct_elt("lifetime", &self.0.lifetime).map(Some),
_ => Ok(None),
}
}
@ -86,7 +86,7 @@ impl<'a, L: Lifetime + Serialize + 'a> ser::MapVisitor for SerVisitor<'a, L> {
impl<L: Lifetime + Deserialize> Deserialize for Bearer<L> {
fn deserialize<D: Deserializer>(deserializer: &mut D) -> Result<Self, D::Error> {
static FIELDS: &'static [&'static str] = &["access_token", "scope", "lifetime"];
deserializer.visit_struct("Bearer", FIELDS, DeVisitor(PhantomData))
deserializer.deserialize_struct("Bearer", FIELDS, DeVisitor(PhantomData))
}
}
@ -135,7 +135,7 @@ enum Field {
impl Deserialize for Field {
fn deserialize<D: Deserializer>(deserializer: &mut D) -> Result<Self, D::Error> {
deserializer.visit(FieldVisitor)
deserializer.deserialize(FieldVisitor)
}
}
@ -148,7 +148,7 @@ impl de::Visitor for FieldVisitor {
"access_token" => Ok(Field::AccessToken),
"scope" => Ok(Field::Scope),
"lifetime" => Ok(Field::Lifetime),
_ => Err(de::Error::syntax("expected access_token, scope or lifetime")),
_ => Err(de::Error::custom("expected access_token, scope or lifetime")),
}
}
}

View File

@ -95,7 +95,7 @@ impl Decodable for Expiring {
impl Serialize for Expiring {
fn serialize<S: Serializer>(&self, serializer: &mut S) -> Result<(), S::Error> {
serializer.visit_struct("Expiring", SerVisitor(self, 0))
serializer.serialize_struct("Expiring", SerVisitor(self, 0))
}
}
@ -104,8 +104,8 @@ impl<'a> ser::MapVisitor for SerVisitor<'a> {
fn visit<S: Serializer>(&mut self, serializer: &mut S) -> Result<Option<()>, S::Error> {
self.1 += 1;
match self.1 {
1 => serializer.visit_struct_elt("refresh_token", &self.0.refresh_token).map(Some),
2 => serializer.visit_struct_elt("expires", &self.0.expires.timestamp()).map(Some),
1 => serializer.serialize_struct_elt("refresh_token", &self.0.refresh_token).map(Some),
2 => serializer.serialize_struct_elt("expires", &self.0.expires.timestamp()).map(Some),
_ => Ok(None),
}
}
@ -116,7 +116,7 @@ impl<'a> ser::MapVisitor for SerVisitor<'a> {
impl Deserialize for Expiring {
fn deserialize<D: Deserializer>(deserializer: &mut D) -> Result<Self, D::Error> {
static FIELDS: &'static [&'static str] = &["refresh_token", "expires"];
deserializer.visit_struct("Expiring", FIELDS, DeVisitor)
deserializer.deserialize_struct("Expiring", FIELDS, DeVisitor)
}
}
@ -161,7 +161,7 @@ enum Field {
impl Deserialize for Field {
fn deserialize<D: Deserializer>(deserializer: &mut D) -> Result<Self, D::Error> {
deserializer.visit(FieldVisitor)
deserializer.deserialize(FieldVisitor)
}
}
@ -173,7 +173,7 @@ impl de::Visitor for FieldVisitor {
match value {
"refresh_token" => Ok(Field::RefreshToken),
"expires" => Ok(Field::Expires),
_ => Err(de::Error::syntax("expected refresh_token or expires")),
_ => Err(de::Error::custom("expected refresh_token or expires")),
}
}
}

View File

@ -25,13 +25,13 @@ impl FromResponse for Static {
impl Serialize for Static {
fn serialize<S: Serializer>(&self, serializer: &mut S) -> Result<(), S::Error> {
serializer.visit_unit_struct("Static")
serializer.serialize_unit_struct("Static")
}
}
impl Deserialize for Static {
fn deserialize<D: Deserializer>(deserializer: &mut D) -> Result<Self, D::Error> {
deserializer.visit_unit_struct("Static", UnitVisitor)
deserializer.deserialize_unit_struct("Static", UnitVisitor)
.and(Ok(Static))
}
}