summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-01-31 10:42:51 +0100
committerAnthony Ramine <n.oxyde@gmail.com>2017-01-31 10:52:21 +0100
commitbc8197c884e7a5dae25b6aedb02eac98145bee92 (patch)
treee9d4f2a79aca78f38ce6101a5cff911a587a19a4 /src
parent2cc32847ac45bee7d0b60020edda3cce7a07b4ce (diff)
Update serde to 0.9.3 and use serde::ser::Impossible
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs3
-rw-r--r--src/ser/mod.rs9
-rw-r--r--src/ser/pair.rs49
-rw-r--r--src/ser/part.rs19
-rw-r--r--src/ser/void.rs122
5 files changed, 40 insertions, 162 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 8fefd77..285a091 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,11 +1,12 @@
//! `x-www-form-urlencoded` meets Serde
+#![warn(unused_extern_crates)]
+
extern crate itoa;
extern crate dtoa;
#[macro_use]
extern crate serde;
extern crate url;
-extern crate void;
pub mod de;
pub mod ser;
diff --git a/src/ser/mod.rs b/src/ser/mod.rs
index 50355fd..f36be4f 100644
--- a/src/ser/mod.rs
+++ b/src/ser/mod.rs
@@ -4,7 +4,6 @@ mod key;
mod pair;
mod part;
mod value;
-mod void;
use serde::ser;
use std::borrow::Cow;
@@ -102,21 +101,21 @@ pub struct SeqSerializer<'output, Target: 'output + UrlEncodedTarget> {
///
/// Never instantiated, tuples are not supported at top-level.
pub struct TupleSerializer<'output, T: 'output + UrlEncodedTarget> {
- inner: void::VoidSerializer<&'output mut UrlEncodedSerializer<T>>,
+ inner: ser::Impossible<&'output mut UrlEncodedSerializer<T>, Error>,
}
/// Tuple struct serializer.
///
/// Never instantiated, tuple structs are not supported.
pub struct TupleStructSerializer<'output, T: 'output + UrlEncodedTarget> {
- inner: void::VoidSerializer<&'output mut UrlEncodedSerializer<T>>,
+ inner: ser::Impossible<&'output mut UrlEncodedSerializer<T>, Error>,
}
/// Tuple variant serializer.
///
/// Never instantiated, tuple variants are not supported.
pub struct TupleVariantSerializer<'output, T: 'output + UrlEncodedTarget> {
- inner: void::VoidSerializer<&'output mut UrlEncodedSerializer<T>>,
+ inner: ser::Impossible<&'output mut UrlEncodedSerializer<T>, Error>,
}
/// Map serializer.
@@ -134,7 +133,7 @@ pub struct StructSerializer<'output, Target: 'output + UrlEncodedTarget> {
///
/// Never instantiated, struct variants are not supported.
pub struct StructVariantSerializer<'output, T: 'output + UrlEncodedTarget> {
- inner: void::VoidSerializer<&'output mut UrlEncodedSerializer<T>>,
+ inner: ser::Impossible<&'output mut UrlEncodedSerializer<T>, Error>,
}
impl<'output, Target> ser::Serializer for Serializer<'output, Target>
diff --git a/src/ser/pair.rs b/src/ser/pair.rs
index 743b3dd..6815647 100644
--- a/src/ser/pair.rs
+++ b/src/ser/pair.rs
@@ -2,7 +2,6 @@ use ser::Error;
use ser::key::KeySink;
use ser::part::PartSerializer;
use ser::value::ValueSink;
-use ser::void::VoidSerializer;
use serde::ser;
use std::borrow::Cow;
use std::mem;
@@ -30,13 +29,13 @@ impl<'target, Target> ser::Serializer for PairSerializer<'target, Target>
{
type Ok = ();
type Error = Error;
- type SerializeSeq = VoidSerializer<()>;
+ type SerializeSeq = ser::Impossible<(), Error>;
type SerializeTuple = Self;
- type SerializeTupleStruct = VoidSerializer<()>;
- type SerializeTupleVariant = VoidSerializer<()>;
- type SerializeMap = VoidSerializer<()>;
- type SerializeStruct = VoidSerializer<()>;
- type SerializeStructVariant = VoidSerializer<()>;
+ type SerializeTupleStruct = ser::Impossible<(), Error>;
+ type SerializeTupleVariant = ser::Impossible<(), Error>;
+ type SerializeMap = ser::Impossible<(), Error>;
+ type SerializeStruct = ser::Impossible<(), Error>;
+ type SerializeStructVariant = ser::Impossible<(), Error>;
fn serialize_bool(self, _v: bool) -> Result<(), Error> {
Err(Error::unsupported_pair())
@@ -140,13 +139,13 @@ impl<'target, Target> ser::Serializer for PairSerializer<'target, Target>
fn serialize_seq(self,
_len: Option<usize>)
- -> Result<VoidSerializer<()>, Error> {
+ -> Result<Self::SerializeSeq, Error> {
Err(Error::unsupported_pair())
}
fn serialize_seq_fixed_size(self,
_len: usize)
- -> Result<VoidSerializer<()>, Error> {
+ -> Result<Self::SerializeSeq, Error> {
Err(Error::unsupported_pair())
}
@@ -161,38 +160,40 @@ impl<'target, Target> ser::Serializer for PairSerializer<'target, Target>
fn serialize_tuple_struct(self,
_name: &'static str,
_len: usize)
- -> Result<VoidSerializer<()>, Error> {
+ -> Result<Self::SerializeTupleStruct, Error> {
Err(Error::unsupported_pair())
}
- fn serialize_tuple_variant(self,
- _name: &'static str,
- _variant_index: usize,
- _variant: &'static str,
- _len: usize)
- -> Result<VoidSerializer<()>, Error> {
+ fn serialize_tuple_variant
+ (self,
+ _name: &'static str,
+ _variant_index: usize,
+ _variant: &'static str,
+ _len: usize)
+ -> Result<Self::SerializeTupleVariant, Error> {
Err(Error::unsupported_pair())
}
fn serialize_map(self,
_len: Option<usize>)
- -> Result<VoidSerializer<()>, Error> {
+ -> Result<Self::SerializeMap, Error> {
Err(Error::unsupported_pair())
}
fn serialize_struct(self,
_name: &'static str,
_len: usize)
- -> Result<VoidSerializer<()>, Error> {
+ -> Result<Self::SerializeStruct, Error> {
Err(Error::unsupported_pair())
}
- fn serialize_struct_variant(self,
- _name: &'static str,
- _variant_index: usize,
- _variant: &'static str,
- _len: usize)
- -> Result<VoidSerializer<()>, Error> {
+ fn serialize_struct_variant
+ (self,
+ _name: &'static str,
+ _variant_index: usize,
+ _variant: &'static str,
+ _len: usize)
+ -> Result<Self::SerializeStructVariant, Error> {
Err(Error::unsupported_pair())
}
}
diff --git a/src/ser/part.rs b/src/ser/part.rs
index e720314..42653c0 100644
--- a/src/ser/part.rs
+++ b/src/ser/part.rs
@@ -1,7 +1,6 @@
use dtoa;
use itoa;
use ser::Error;
-use ser::void::VoidSerializer;
use serde::ser;
use std::str;
@@ -37,13 +36,13 @@ pub trait Sink: Sized {
impl<S: Sink> ser::Serializer for PartSerializer<S> {
type Ok = S::Ok;
type Error = Error;
- type SerializeSeq = VoidSerializer<S::Ok>;
- type SerializeTuple = VoidSerializer<S::Ok>;
- type SerializeTupleStruct = VoidSerializer<S::Ok>;
- type SerializeTupleVariant = VoidSerializer<S::Ok>;
- type SerializeMap = VoidSerializer<S::Ok>;
- type SerializeStruct = VoidSerializer<S::Ok>;
- type SerializeStructVariant = VoidSerializer<S::Ok>;
+ type SerializeSeq = ser::Impossible<S::Ok, Error>;
+ type SerializeTuple = ser::Impossible<S::Ok, Error>;
+ type SerializeTupleStruct = ser::Impossible<S::Ok, Error>;
+ type SerializeTupleVariant = ser::Impossible<S::Ok, Error>;
+ type SerializeMap = ser::Impossible<S::Ok, Error>;
+ type SerializeStruct = ser::Impossible<S::Ok, Error>;
+ type SerializeStructVariant = ser::Impossible<S::Ok, Error>;
fn serialize_bool(self, v: bool) -> Result<S::Ok, Error> {
self.sink.serialize_static_str(if v { "true" } else { "false" })
@@ -210,7 +209,7 @@ impl<S: Sink> ser::Serializer for PartSerializer<S> {
impl<S: Sink> PartSerializer<S> {
fn serialize_integer<I>(self, value: I) -> Result<S::Ok, Error>
- where I: itoa::Integer
+ where I: itoa::Integer,
{
let mut buf = [b'\0'; 20];
let len = itoa::write(&mut buf[..], value).unwrap();
@@ -219,7 +218,7 @@ impl<S: Sink> PartSerializer<S> {
}
fn serialize_floating<F>(self, value: F) -> Result<S::Ok, Error>
- where F: dtoa::Floating
+ where F: dtoa::Floating,
{
let mut buf = [b'\0'; 24];
let len = dtoa::write(&mut buf[..], value).unwrap();
diff --git a/src/ser/void.rs b/src/ser/void.rs
deleted file mode 100644
index 4765bb7..0000000
--- a/src/ser/void.rs
+++ /dev/null
@@ -1,122 +0,0 @@
-use ser::Error;
-use serde::ser;
-use std::marker::PhantomData;
-use void;
-
-pub struct VoidSerializer<Ok> {
- void: void::Void,
- _marker: PhantomData<Ok>,
-}
-
-impl<Ok> ser::SerializeSeq for VoidSerializer<Ok> {
- type Ok = Ok;
- type Error = Error;
-
- fn serialize_element<T: ?Sized + ser::Serialize>(&mut self,
- _value: &T)
- -> Result<(), Error> {
- void::unreachable(self.void)
- }
-
- fn end(self) -> Result<Ok, Error> {
- void::unreachable(self.void)
- }
-}
-
-impl<Ok> ser::SerializeTuple for VoidSerializer<Ok> {
- type Ok = Ok;
- type Error = Error;
-
- fn serialize_element<T: ?Sized + ser::Serialize>(&mut self,
- _value: &T)
- -> Result<(), Error> {
- void::unreachable(self.void)
- }
-
- fn end(self) -> Result<Ok, Error> {
- void::unreachable(self.void)
- }
-}
-
-impl<Ok> ser::SerializeTupleStruct for VoidSerializer<Ok> {
- type Ok = Ok;
- type Error = Error;
-
- fn serialize_field<T: ?Sized + ser::Serialize>(&mut self,
- _value: &T)
- -> Result<(), Error> {
- void::unreachable(self.void)
- }
-
- fn end(self) -> Result<Ok, Error> {
- void::unreachable(self.void)
- }
-}
-
-impl<Ok> ser::SerializeTupleVariant for VoidSerializer<Ok> {
- type Ok = Ok;
- type Error = Error;
-
- fn serialize_field<T: ?Sized + ser::Serialize>(&mut self,
- _value: &T)
- -> Result<(), Error> {
- void::unreachable(self.void)
- }
-
- fn end(self) -> Result<Ok, Error> {
- void::unreachable(self.void)
- }
-}
-
-impl<Ok> ser::SerializeMap for VoidSerializer<Ok> {
- type Ok = Ok;
- type Error = Error;
-
- fn serialize_key<T: ?Sized + ser::Serialize>(&mut self,
- _key: &T)
- -> Result<(), Error> {
- void::unreachable(self.void)
- }
-
- fn serialize_value<T: ?Sized + ser::Serialize>(&mut self,
- _value: &T)
- -> Result<(), Error> {
- void::unreachable(self.void)
- }
-
- fn end(self) -> Result<Ok, Error> {
- void::unreachable(self.void)
- }
-}
-
-impl<Ok> ser::SerializeStruct for VoidSerializer<Ok> {
- type Ok = Ok;
- type Error = Error;
-
- fn serialize_field<T: ?Sized + ser::Serialize>(&mut self,
- _key: &'static str,
- _value: &T)
- -> Result<(), Error> {
- void::unreachable(self.void)
- }
-
- fn end(self) -> Result<Ok, Error> {
- void::unreachable(self.void)
- }
-}
-
-impl<Ok> ser::SerializeStructVariant for VoidSerializer<Ok> {
- type Ok = Ok;
- type Error = Error;
-
- fn serialize_field<T: ?Sized + ser::Serialize>(&mut self,
- _key: &'static str,
- _value: &T)
- -> Result<(), Error> {
- void::unreachable(self.void)
- }
-
- fn end(self) -> Result<Ok, Error> {
- void::unreachable(self.void)
- }
-}