mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-05-31 02:51:05 +00:00
Match the associated types from the Serializer trait
This commit is contained in:
+38
-38
@@ -61,133 +61,133 @@ use ser::{self, Serialize, SerializeSeq, SerializeTuple, SerializeTupleStruct,
|
|||||||
/// [`SerializeMap`]: trait.SerializeMap.html
|
/// [`SerializeMap`]: trait.SerializeMap.html
|
||||||
/// [`SerializeStruct`]: trait.SerializeStruct.html
|
/// [`SerializeStruct`]: trait.SerializeStruct.html
|
||||||
/// [`SerializeStructVariant`]: trait.SerializeStructVariant.html
|
/// [`SerializeStructVariant`]: trait.SerializeStructVariant.html
|
||||||
pub struct Impossible<Ok, E> {
|
pub struct Impossible<Ok, Error> {
|
||||||
void: Void,
|
void: Void,
|
||||||
_marker: PhantomData<(Ok, E)>,
|
_marker: PhantomData<(Ok, Error)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Void {}
|
enum Void {}
|
||||||
|
|
||||||
impl<Ok, E> SerializeSeq for Impossible<Ok, E>
|
impl<Ok, Error> SerializeSeq for Impossible<Ok, Error>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
Error: ser::Error,
|
||||||
{
|
{
|
||||||
type Ok = Ok;
|
type Ok = Ok;
|
||||||
type Error = E;
|
type Error = Error;
|
||||||
|
|
||||||
fn serialize_element<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
|
fn serialize_element<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn end(self) -> Result<Ok, E> {
|
fn end(self) -> Result<Ok, Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Ok, E> SerializeTuple for Impossible<Ok, E>
|
impl<Ok, Error> SerializeTuple for Impossible<Ok, Error>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
Error: ser::Error,
|
||||||
{
|
{
|
||||||
type Ok = Ok;
|
type Ok = Ok;
|
||||||
type Error = E;
|
type Error = Error;
|
||||||
|
|
||||||
fn serialize_element<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
|
fn serialize_element<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn end(self) -> Result<Ok, E> {
|
fn end(self) -> Result<Ok, Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Ok, E> SerializeTupleStruct for Impossible<Ok, E>
|
impl<Ok, Error> SerializeTupleStruct for Impossible<Ok, Error>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
Error: ser::Error,
|
||||||
{
|
{
|
||||||
type Ok = Ok;
|
type Ok = Ok;
|
||||||
type Error = E;
|
type Error = Error;
|
||||||
|
|
||||||
fn serialize_field<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
|
fn serialize_field<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn end(self) -> Result<Ok, E> {
|
fn end(self) -> Result<Ok, Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Ok, E> SerializeTupleVariant for Impossible<Ok, E>
|
impl<Ok, Error> SerializeTupleVariant for Impossible<Ok, Error>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
Error: ser::Error,
|
||||||
{
|
{
|
||||||
type Ok = Ok;
|
type Ok = Ok;
|
||||||
type Error = E;
|
type Error = Error;
|
||||||
|
|
||||||
fn serialize_field<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
|
fn serialize_field<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn end(self) -> Result<Ok, E> {
|
fn end(self) -> Result<Ok, Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Ok, E> SerializeMap for Impossible<Ok, E>
|
impl<Ok, Error> SerializeMap for Impossible<Ok, Error>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
Error: ser::Error,
|
||||||
{
|
{
|
||||||
type Ok = Ok;
|
type Ok = Ok;
|
||||||
type Error = E;
|
type Error = Error;
|
||||||
|
|
||||||
fn serialize_key<T: ?Sized + Serialize>(&mut self, _key: &T) -> Result<(), E> {
|
fn serialize_key<T: ?Sized + Serialize>(&mut self, _key: &T) -> Result<(), Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_value<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), E> {
|
fn serialize_value<T: ?Sized + Serialize>(&mut self, _value: &T) -> Result<(), Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn end(self) -> Result<Ok, E> {
|
fn end(self) -> Result<Ok, Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Ok, E> SerializeStruct for Impossible<Ok, E>
|
impl<Ok, Error> SerializeStruct for Impossible<Ok, Error>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
Error: ser::Error,
|
||||||
{
|
{
|
||||||
type Ok = Ok;
|
type Ok = Ok;
|
||||||
type Error = E;
|
type Error = Error;
|
||||||
|
|
||||||
fn serialize_field<T: ?Sized + Serialize>(
|
fn serialize_field<T: ?Sized + Serialize>(
|
||||||
&mut self,
|
&mut self,
|
||||||
_key: &'static str,
|
_key: &'static str,
|
||||||
_value: &T,
|
_value: &T,
|
||||||
) -> Result<(), E> {
|
) -> Result<(), Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn end(self) -> Result<Ok, E> {
|
fn end(self) -> Result<Ok, Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Ok, E> SerializeStructVariant for Impossible<Ok, E>
|
impl<Ok, Error> SerializeStructVariant for Impossible<Ok, Error>
|
||||||
where
|
where
|
||||||
E: ser::Error,
|
Error: ser::Error,
|
||||||
{
|
{
|
||||||
type Ok = Ok;
|
type Ok = Ok;
|
||||||
type Error = E;
|
type Error = Error;
|
||||||
|
|
||||||
fn serialize_field<T: ?Sized + Serialize>(
|
fn serialize_field<T: ?Sized + Serialize>(
|
||||||
&mut self,
|
&mut self,
|
||||||
_key: &'static str,
|
_key: &'static str,
|
||||||
_value: &T,
|
_value: &T,
|
||||||
) -> Result<(), E> {
|
) -> Result<(), Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn end(self) -> Result<Ok, E> {
|
fn end(self) -> Result<Ok, Error> {
|
||||||
match self.void {}
|
match self.void {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user