Converted serde serialization to new style
This commit is contained in:
parent
753609918e
commit
f43e2e13c7
1 changed files with 5 additions and 35 deletions
|
@ -197,41 +197,11 @@ mod eders_ser {
|
|||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
||||
where S: serde::Serializer
|
||||
{
|
||||
serializer.serialize_struct("Decomposed", DecomposedVisitor {
|
||||
value: self,
|
||||
state: 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
struct DecomposedVisitor<'a, V: 'a + VectorSpace, R: 'a> {
|
||||
value: &'a Decomposed<V, R>,
|
||||
state: u8,
|
||||
}
|
||||
|
||||
impl<'a, V: 'a + VectorSpace, R> serde::ser::MapVisitor for DecomposedVisitor<'a, V, R>
|
||||
where V: Serialize, V::Scalar: Serialize, R: Serialize
|
||||
{
|
||||
fn visit<S>(&mut self, serializer: &mut S) -> Result<Option<()>, S::Error>
|
||||
where S: serde::Serializer
|
||||
{
|
||||
match self.state {
|
||||
0 => {
|
||||
self.state += 1;
|
||||
Ok(Some(try!(serializer.serialize_struct_elt("scale", &self.value.scale))))
|
||||
},
|
||||
1 => {
|
||||
self.state += 1;
|
||||
Ok(Some(try!(serializer.serialize_struct_elt("rot", &self.value.rot))))
|
||||
},
|
||||
2 => {
|
||||
self.state += 1;
|
||||
Ok(Some(try!(serializer.serialize_struct_elt("disp", &self.value.disp))))
|
||||
},
|
||||
_ => {
|
||||
Ok(None)
|
||||
},
|
||||
}
|
||||
let mut state = try!(serializer.serialize_struct("Decomposed", 3));
|
||||
try!(serializer.serialize_struct_elt(&mut state, "scale", &self.scale));
|
||||
try!(serializer.serialize_struct_elt(&mut state, "rot", &self.rot));
|
||||
try!(serializer.serialize_struct_elt(&mut state, "disp", &self.disp));
|
||||
serializer.serialize_struct_end(state)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue