summaryrefslogtreecommitdiffstats
path: root/vendor/serde/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vendor/serde/src/de/ignored_any.rs2
-rw-r--r--vendor/serde/src/de/impls.rs8
-rw-r--r--vendor/serde/src/de/mod.rs24
-rw-r--r--vendor/serde/src/de/value.rs37
-rw-r--r--vendor/serde/src/lib.rs24
-rw-r--r--vendor/serde/src/private/de.rs11
-rw-r--r--vendor/serde/src/private/ser.rs6
-rw-r--r--vendor/serde/src/ser/impls.rs15
-rw-r--r--vendor/serde/src/ser/mod.rs8
9 files changed, 96 insertions, 39 deletions
diff --git a/vendor/serde/src/de/ignored_any.rs b/vendor/serde/src/de/ignored_any.rs
index 1d50f5ec3..9ed438e79 100644
--- a/vendor/serde/src/de/ignored_any.rs
+++ b/vendor/serde/src/de/ignored_any.rs
@@ -228,7 +228,7 @@ impl<'de> Visitor<'de> for IgnoredAny {
where
A: EnumAccess<'de>,
{
- data.variant::<IgnoredAny>()?.1.newtype_variant()
+ try!(data.variant::<IgnoredAny>()).1.newtype_variant()
}
}
diff --git a/vendor/serde/src/de/impls.rs b/vendor/serde/src/de/impls.rs
index c2a56b4fc..c048f7145 100644
--- a/vendor/serde/src/de/impls.rs
+++ b/vendor/serde/src/de/impls.rs
@@ -2268,14 +2268,14 @@ where
where
D: Deserializer<'de>,
{
- let (start, end) = deserializer.deserialize_struct(
+ let (start, end) = try!(deserializer.deserialize_struct(
"Range",
range::FIELDS,
range::RangeVisitor {
expecting: "struct Range",
phantom: PhantomData,
},
- )?;
+ ));
Ok(start..end)
}
}
@@ -2289,14 +2289,14 @@ where
where
D: Deserializer<'de>,
{
- let (start, end) = deserializer.deserialize_struct(
+ let (start, end) = try!(deserializer.deserialize_struct(
"RangeInclusive",
range::FIELDS,
range::RangeVisitor {
expecting: "struct RangeInclusive",
phantom: PhantomData,
},
- )?;
+ ));
Ok(RangeInclusive::new(start, end))
}
}
diff --git a/vendor/serde/src/de/mod.rs b/vendor/serde/src/de/mod.rs
index 6100815f7..d9dafbe1e 100644
--- a/vendor/serde/src/de/mod.rs
+++ b/vendor/serde/src/de/mod.rs
@@ -30,7 +30,7 @@
//! # The Deserializer trait
//!
//! [`Deserializer`] implementations are provided by third-party crates, for
-//! example [`serde_json`], [`serde_yaml`] and [`bincode`].
+//! example [`serde_json`], [`serde_yaml`] and [`postcard`].
//!
//! A partial list of well-maintained formats is given on the [Serde
//! website][data formats].
@@ -104,7 +104,7 @@
//! [`Deserialize`]: ../trait.Deserialize.html
//! [`Deserializer`]: ../trait.Deserializer.html
//! [`LinkedHashMap<K, V>`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html
-//! [`bincode`]: https://github.com/bincode-org/bincode
+//! [`postcard`]: https://github.com/jamesmunns/postcard
//! [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
//! [`serde_derive`]: https://crates.io/crates/serde_derive
//! [`serde_json`]: https://github.com/serde-rs/json
@@ -565,7 +565,7 @@ pub trait Deserialize<'de>: Sized {
D: Deserializer<'de>,
{
// Default implementation just delegates to `deserialize` impl.
- *place = Deserialize::deserialize(deserializer)?;
+ *place = try!(Deserialize::deserialize(deserializer));
Ok(())
}
}
@@ -862,10 +862,10 @@ where
/// The `Deserializer` trait supports two entry point styles which enables
/// different kinds of deserialization.
///
-/// 1. The `deserialize` method. Self-describing data formats like JSON are able
-/// to look at the serialized data and tell what it represents. For example
-/// the JSON deserializer may see an opening curly brace (`{`) and know that
-/// it is seeing a map. If the data format supports
+/// 1. The `deserialize_any` method. Self-describing data formats like JSON are
+/// able to look at the serialized data and tell what it represents. For
+/// example the JSON deserializer may see an opening curly brace (`{`) and
+/// know that it is seeing a map. If the data format supports
/// `Deserializer::deserialize_any`, it will drive the Visitor using whatever
/// type it sees in the input. JSON uses this approach when deserializing
/// `serde_json::Value` which is an enum that can represent any JSON
@@ -874,7 +874,7 @@ where
/// `Deserializer::deserialize_any`.
///
/// 2. The various `deserialize_*` methods. Non-self-describing formats like
-/// Bincode need to be told what is in the input in order to deserialize it.
+/// Postcard need to be told what is in the input in order to deserialize it.
/// The `deserialize_*` methods are hints to the deserializer for how to
/// interpret the next piece of input. Non-self-describing formats are not
/// able to deserialize something like `serde_json::Value` which relies on
@@ -884,7 +884,7 @@ where
/// `Deserializer::deserialize_any` unless you need to be told by the
/// Deserializer what type is in the input. Know that relying on
/// `Deserializer::deserialize_any` means your data type will be able to
-/// deserialize from self-describing formats only, ruling out Bincode and many
+/// deserialize from self-describing formats only, ruling out Postcard and many
/// others.
///
/// [Serde data model]: https://serde.rs/data-model.html
@@ -915,7 +915,7 @@ pub trait Deserializer<'de>: Sized {
/// `Deserializer::deserialize_any` unless you need to be told by the
/// Deserializer what type is in the input. Know that relying on
/// `Deserializer::deserialize_any` means your data type will be able to
- /// deserialize from self-describing formats only, ruling out Bincode and
+ /// deserialize from self-describing formats only, ruling out Postcard and
/// many others.
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where
@@ -1156,7 +1156,7 @@ pub trait Deserializer<'de>: Sized {
/// Some types have a human-readable form that may be somewhat expensive to
/// construct, as well as a binary form that is compact and efficient.
/// Generally text-based formats like JSON and YAML will prefer to use the
- /// human-readable one and binary formats like Bincode will prefer the
+ /// human-readable one and binary formats like Postcard will prefer the
/// compact one.
///
/// ```edition2018
@@ -1560,7 +1560,7 @@ pub trait Visitor<'de>: Sized {
/// `Deserializer`.
///
/// This enables zero-copy deserialization of bytes in some formats. For
- /// example Bincode data containing bytes can be deserialized with zero
+ /// example Postcard data containing bytes can be deserialized with zero
/// copying into a `&'a [u8]` as long as the input data outlives `'a`.
///
/// The default implementation forwards to `visit_bytes`.
diff --git a/vendor/serde/src/de/value.rs b/vendor/serde/src/de/value.rs
index e7afdd8d1..5d8886215 100644
--- a/vendor/serde/src/de/value.rs
+++ b/vendor/serde/src/de/value.rs
@@ -1501,7 +1501,7 @@ where
where
T: de::DeserializeSeed<'de>,
{
- match self.map.next_key_seed(seed)? {
+ match try!(self.map.next_key_seed(seed)) {
Some(key) => Ok((key, private::map_as_enum(self.map))),
None => Err(de::Error::invalid_type(de::Unexpected::Map, &"enum")),
}
@@ -1510,6 +1510,41 @@ where
////////////////////////////////////////////////////////////////////////////////
+/// A deserializer holding an `EnumAccess`.
+#[derive(Clone, Debug)]
+pub struct EnumAccessDeserializer<A> {
+ access: A,
+}
+
+impl<A> EnumAccessDeserializer<A> {
+ /// Construct a new `EnumAccessDeserializer<A>`.
+ pub fn new(access: A) -> Self {
+ EnumAccessDeserializer { access: access }
+ }
+}
+
+impl<'de, A> de::Deserializer<'de> for EnumAccessDeserializer<A>
+where
+ A: de::EnumAccess<'de>,
+{
+ type Error = A::Error;
+
+ fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
+ where
+ V: de::Visitor<'de>,
+ {
+ visitor.visit_enum(self.access)
+ }
+
+ forward_to_deserialize_any! {
+ bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
+ bytes byte_buf option unit unit_struct newtype_struct seq tuple
+ tuple_struct map struct enum identifier ignored_any
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
mod private {
use lib::*;
diff --git a/vendor/serde/src/lib.rs b/vendor/serde/src/lib.rs
index f1a17513c..02c57ae9d 100644
--- a/vendor/serde/src/lib.rs
+++ b/vendor/serde/src/lib.rs
@@ -31,8 +31,7 @@
//! for Serde by the community.
//!
//! - [JSON], the ubiquitous JavaScript Object Notation used by many HTTP APIs.
-//! - [Bincode], a compact binary format
-//! used for IPC within the Servo rendering engine.
+//! - [Postcard], a no\_std and embedded-systems friendly compact binary format.
//! - [CBOR], a Concise Binary Object Representation designed for small message
//! size without the need for version negotiation.
//! - [YAML], a self-proclaimed human-friendly configuration language that ain't
@@ -45,7 +44,6 @@
//! - [Avro], a binary format used within Apache Hadoop, with support for schema
//! definition.
//! - [JSON5], a superset of JSON including some productions from ES5.
-//! - [Postcard], a no\_std and embedded-systems friendly compact binary format.
//! - [URL] query strings, in the x-www-form-urlencoded format.
//! - [Envy], a way to deserialize environment variables into Rust structs.
//! *(deserialization only)*
@@ -59,7 +57,7 @@
//! and from DynamoDB.
//!
//! [JSON]: https://github.com/serde-rs/json
-//! [Bincode]: https://github.com/bincode-org/bincode
+//! [Postcard]: https://github.com/jamesmunns/postcard
//! [CBOR]: https://github.com/enarx/ciborium
//! [YAML]: https://github.com/dtolnay/serde-yaml
//! [MessagePack]: https://github.com/3Hren/msgpack-rust
@@ -67,9 +65,8 @@
//! [Pickle]: https://github.com/birkenfeld/serde-pickle
//! [RON]: https://github.com/ron-rs/ron
//! [BSON]: https://github.com/mongodb/bson-rust
-//! [Avro]: https://github.com/flavray/avro-rs
+//! [Avro]: https://docs.rs/apache-avro
//! [JSON5]: https://github.com/callum-oakley/json5-rs
-//! [Postcard]: https://github.com/jamesmunns/postcard
//! [URL]: https://docs.rs/serde_qs
//! [Envy]: https://github.com/softprops/envy
//! [Envy Store]: https://github.com/softprops/envy-store
@@ -84,7 +81,7 @@
////////////////////////////////////////////////////////////////////////////////
// Serde types in rustdoc of other crates get linked to here.
-#![doc(html_root_url = "https://docs.rs/serde/1.0.140")]
+#![doc(html_root_url = "https://docs.rs/serde/1.0.147")]
// Support using Serde without the standard library!
#![cfg_attr(not(feature = "std"), no_std)]
// Unstable functionality only if the user asks for it. For tracking and
@@ -252,6 +249,19 @@ mod lib {
pub use self::core::time::Duration;
}
+// None of this crate's error handling needs the `From::from` error conversion
+// performed implicitly by the `?` operator or the standard library's `try!`
+// macro. This simplified macro gives a 5.5% improvement in compile time
+// compared to standard `try!`, and 9% improvement compared to `?`.
+macro_rules! try {
+ ($expr:expr) => {
+ match $expr {
+ Ok(val) => val,
+ Err(err) => return Err(err),
+ }
+ };
+}
+
////////////////////////////////////////////////////////////////////////////////
#[macro_use]
diff --git a/vendor/serde/src/private/de.rs b/vendor/serde/src/private/de.rs
index f0697d64f..01e5bf787 100644
--- a/vendor/serde/src/private/de.rs
+++ b/vendor/serde/src/private/de.rs
@@ -1262,6 +1262,17 @@ mod content {
{
match self.content {
Content::Unit => visitor.visit_unit(),
+
+ // Allow deserializing newtype variant containing unit.
+ //
+ // #[derive(Deserialize)]
+ // #[serde(tag = "result")]
+ // enum Response<T> {
+ // Success(T),
+ // }
+ //
+ // We want {"result":"Success"} to deserialize into Response<()>.
+ Content::Map(ref v) if v.is_empty() => visitor.visit_unit(),
_ => Err(self.invalid_type(&visitor)),
}
}
diff --git a/vendor/serde/src/private/ser.rs b/vendor/serde/src/private/ser.rs
index 6ee999389..293d8a865 100644
--- a/vendor/serde/src/private/ser.rs
+++ b/vendor/serde/src/private/ser.rs
@@ -51,7 +51,6 @@ enum Unsupported {
String,
ByteArray,
Optional,
- Unit,
#[cfg(any(feature = "std", feature = "alloc"))]
UnitStruct,
Sequence,
@@ -70,7 +69,6 @@ impl Display for Unsupported {
Unsupported::String => formatter.write_str("a string"),
Unsupported::ByteArray => formatter.write_str("a byte array"),
Unsupported::Optional => formatter.write_str("an optional"),
- Unsupported::Unit => formatter.write_str("unit"),
#[cfg(any(feature = "std", feature = "alloc"))]
Unsupported::UnitStruct => formatter.write_str("unit struct"),
Unsupported::Sequence => formatter.write_str("a sequence"),
@@ -184,7 +182,9 @@ where
}
fn serialize_unit(self) -> Result<Self::Ok, Self::Error> {
- Err(self.bad_type(Unsupported::Unit))
+ let mut map = try!(self.delegate.serialize_map(Some(1)));
+ try!(map.serialize_entry(self.tag, self.variant_name));
+ map.end()
}
fn serialize_unit_struct(self, _: &'static str) -> Result<Self::Ok, Self::Error> {
diff --git a/vendor/serde/src/ser/impls.rs b/vendor/serde/src/ser/impls.rs
index 7219f51b7..8e8655582 100644
--- a/vendor/serde/src/ser/impls.rs
+++ b/vendor/serde/src/ser/impls.rs
@@ -522,7 +522,7 @@ where
}
}
-impl<T> Serialize for RefCell<T>
+impl<T: ?Sized> Serialize for RefCell<T>
where
T: Serialize,
{
@@ -538,7 +538,7 @@ where
}
#[cfg(feature = "std")]
-impl<T> Serialize for Mutex<T>
+impl<T: ?Sized> Serialize for Mutex<T>
where
T: Serialize,
{
@@ -554,7 +554,7 @@ where
}
#[cfg(feature = "std")]
-impl<T> Serialize for RwLock<T>
+impl<T: ?Sized> Serialize for RwLock<T>
where
T: Serialize,
{
@@ -614,9 +614,10 @@ impl Serialize for SystemTime {
S: Serializer,
{
use super::SerializeStruct;
- let duration_since_epoch = self
- .duration_since(UNIX_EPOCH)
- .map_err(|_| S::Error::custom("SystemTime must be later than UNIX_EPOCH"))?;
+ let duration_since_epoch = match self.duration_since(UNIX_EPOCH) {
+ Ok(duration_since_epoch) => duration_since_epoch,
+ Err(_) => return Err(S::Error::custom("SystemTime must be later than UNIX_EPOCH")),
+ };
let mut state = try!(serializer.serialize_struct("SystemTime", 2));
try!(state.serialize_field("secs_since_epoch", &duration_since_epoch.as_secs()));
try!(state.serialize_field("nanos_since_epoch", &duration_since_epoch.subsec_nanos()));
@@ -916,7 +917,7 @@ macro_rules! atomic_impl {
S: Serializer,
{
// Matches the atomic ordering used in libcore for the Debug impl
- self.load(Ordering::SeqCst).serialize(serializer)
+ self.load(Ordering::Relaxed).serialize(serializer)
}
}
)*
diff --git a/vendor/serde/src/ser/mod.rs b/vendor/serde/src/ser/mod.rs
index eb226ae96..9a21363d6 100644
--- a/vendor/serde/src/ser/mod.rs
+++ b/vendor/serde/src/ser/mod.rs
@@ -30,7 +30,7 @@
//! # The Serializer trait
//!
//! [`Serializer`] implementations are provided by third-party crates, for
-//! example [`serde_json`], [`serde_yaml`] and [`bincode`].
+//! example [`serde_json`], [`serde_yaml`] and [`postcard`].
//!
//! A partial list of well-maintained formats is given on the [Serde
//! website][data formats].
@@ -99,7 +99,7 @@
//! [`LinkedHashMap<K, V>`]: https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html
//! [`Serialize`]: ../trait.Serialize.html
//! [`Serializer`]: ../trait.Serializer.html
-//! [`bincode`]: https://github.com/bincode-org/bincode
+//! [`postcard`]: https://github.com/jamesmunns/postcard
//! [`linked-hash-map`]: https://crates.io/crates/linked-hash-map
//! [`serde_derive`]: https://crates.io/crates/serde_derive
//! [`serde_json`]: https://github.com/serde-rs/json
@@ -314,7 +314,7 @@ pub trait Serialize {
/// - For example the `E::S` in `enum E { S { r: u8, g: u8, b: u8 } }`.
///
/// Many Serde serializers produce text or binary data as output, for example
-/// JSON or Bincode. This is not a requirement of the `Serializer` trait, and
+/// JSON or Postcard. This is not a requirement of the `Serializer` trait, and
/// there are serializers that do not produce text or binary output. One example
/// is the `serde_json::value::Serializer` (distinct from the main `serde_json`
/// serializer) that produces a `serde_json::Value` data structure in memory as
@@ -1423,7 +1423,7 @@ pub trait Serializer: Sized {
/// Some types have a human-readable form that may be somewhat expensive to
/// construct, as well as a binary form that is compact and efficient.
/// Generally text-based formats like JSON and YAML will prefer to use the
- /// human-readable one and binary formats like Bincode will prefer the
+ /// human-readable one and binary formats like Postcard will prefer the
/// compact one.
///
/// ```edition2018