use ser::Error; use serde::ser; use std::marker::PhantomData; use void; pub struct VoidSerializer { void: void::Void, _marker: PhantomData, } impl ser::SerializeSeq for VoidSerializer { type Ok = Ok; type Error = Error; fn serialize_element(&mut self, _value: &T) -> Result<(), Error> { void::unreachable(self.void) } fn end(self) -> Result { void::unreachable(self.void) } } impl ser::SerializeTuple for VoidSerializer { type Ok = Ok; type Error = Error; fn serialize_element(&mut self, _value: &T) -> Result<(), Error> { void::unreachable(self.void) } fn end(self) -> Result { void::unreachable(self.void) } } impl ser::SerializeTupleStruct for VoidSerializer { type Ok = Ok; type Error = Error; fn serialize_field(&mut self, _value: &T) -> Result<(), Error> { void::unreachable(self.void) } fn end(self) -> Result { void::unreachable(self.void) } } impl ser::SerializeTupleVariant for VoidSerializer { type Ok = Ok; type Error = Error; fn serialize_field(&mut self, _value: &T) -> Result<(), Error> { void::unreachable(self.void) } fn end(self) -> Result { void::unreachable(self.void) } } impl ser::SerializeMap for VoidSerializer { type Ok = Ok; type Error = Error; fn serialize_key(&mut self, _key: &T) -> Result<(), Error> { void::unreachable(self.void) } fn serialize_value(&mut self, _value: &T) -> Result<(), Error> { void::unreachable(self.void) } fn end(self) -> Result { void::unreachable(self.void) } } impl ser::SerializeStruct for VoidSerializer { type Ok = Ok; type Error = Error; fn serialize_field(&mut self, _key: &'static str, _value: &T) -> Result<(), Error> { void::unreachable(self.void) } fn end(self) -> Result { void::unreachable(self.void) } } impl ser::SerializeStructVariant for VoidSerializer { type Ok = Ok; type Error = Error; fn serialize_field(&mut self, _key: &'static str, _value: &T) -> Result<(), Error> { void::unreachable(self.void) } fn end(self) -> Result { void::unreachable(self.void) } }