mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-23 05:58:01 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cab653e7c7 | |||
| 8d999a8edd | |||
| 7b773ac088 | |||
| fc58ea7487 | |||
| c61cea0eb1 | |||
| 764b25bd07 | |||
| a66cd25787 | |||
| 0e8d94750b |
@@ -556,3 +556,14 @@ impl serde::de::Visitor for PointVisitor {
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Serialization Formats Using Serde
|
||||
=================================
|
||||
|
||||
| Format | Name |
|
||||
| ------ | ---- |
|
||||
| Bincode | [bincode](https://crates.io/crates/bincode) |
|
||||
| JSON | [serde\_json](https://crates.io/crates/serde_json) |
|
||||
| MessagePack | [rmp](https://crates.io/crates/rmp) |
|
||||
| XML | [serde\_xml](https://github.com/serde-rs/xml) |
|
||||
| YAML | [serde\_yaml](https://github.com/serde-rs/yaml/) |
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "serde"
|
||||
version = "0.5.1"
|
||||
version = "0.5.2"
|
||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "A generic serialization/deserialization framework"
|
||||
|
||||
@@ -10,8 +10,6 @@ use std::collections::{
|
||||
};
|
||||
#[cfg(feature = "nightly")]
|
||||
use collections::enum_set::{CLike, EnumSet};
|
||||
#[cfg(feature = "nightly")]
|
||||
use collections::vec_map::VecMap;
|
||||
use std::hash::Hash;
|
||||
use std::marker::PhantomData;
|
||||
use std::path;
|
||||
@@ -719,64 +717,6 @@ map_impl!(
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
pub struct VecMapVisitor<V> {
|
||||
marker: PhantomData<VecMap<V>>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
impl<V> VecMapVisitor<V> {
|
||||
#[inline]
|
||||
pub fn new() -> Self {
|
||||
VecMapVisitor {
|
||||
marker: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
impl<V> Visitor for VecMapVisitor<V>
|
||||
where V: Deserialize,
|
||||
{
|
||||
type Value = VecMap<V>;
|
||||
|
||||
#[inline]
|
||||
fn visit_unit<E>(&mut self) -> Result<VecMap<V>, E>
|
||||
where E: Error,
|
||||
{
|
||||
Ok(VecMap::new())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_map<V_>(&mut self, mut visitor: V_) -> Result<VecMap<V>, V_::Error>
|
||||
where V_: MapVisitor,
|
||||
{
|
||||
let (len, _) = visitor.size_hint();
|
||||
let mut values = VecMap::with_capacity(len);
|
||||
|
||||
while let Some((key, value)) = try!(visitor.visit()) {
|
||||
values.insert(key, value);
|
||||
}
|
||||
|
||||
try!(visitor.end());
|
||||
|
||||
Ok(values)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
impl<V> Deserialize for VecMap<V>
|
||||
where V: Deserialize,
|
||||
{
|
||||
fn deserialize<D>(deserializer: &mut D) -> Result<VecMap<V>, D::Error>
|
||||
where D: Deserializer,
|
||||
{
|
||||
deserializer.visit_map(VecMapVisitor::new())
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct PathBufVisitor;
|
||||
|
||||
impl Visitor for PathBufVisitor {
|
||||
|
||||
+9
-9
@@ -108,7 +108,7 @@ pub trait Deserializer {
|
||||
fn visit_usize<V>(&mut self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
self.visit(visitor)
|
||||
self.visit_u64(visitor)
|
||||
}
|
||||
|
||||
/// This method hints that the `Deserialize` type is expecting an `u8` value.
|
||||
@@ -116,7 +116,7 @@ pub trait Deserializer {
|
||||
fn visit_u8<V>(&mut self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
self.visit(visitor)
|
||||
self.visit_u64(visitor)
|
||||
}
|
||||
|
||||
/// This method hints that the `Deserialize` type is expecting an `u16` value.
|
||||
@@ -124,7 +124,7 @@ pub trait Deserializer {
|
||||
fn visit_u16<V>(&mut self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
self.visit(visitor)
|
||||
self.visit_u64(visitor)
|
||||
}
|
||||
|
||||
/// This method hints that the `Deserialize` type is expecting an `u32` value.
|
||||
@@ -132,7 +132,7 @@ pub trait Deserializer {
|
||||
fn visit_u32<V>(&mut self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
self.visit(visitor)
|
||||
self.visit_u64(visitor)
|
||||
}
|
||||
|
||||
/// This method hints that the `Deserialize` type is expecting an `u64` value.
|
||||
@@ -148,7 +148,7 @@ pub trait Deserializer {
|
||||
fn visit_isize<V>(&mut self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
self.visit(visitor)
|
||||
self.visit_i64(visitor)
|
||||
}
|
||||
|
||||
/// This method hints that the `Deserialize` type is expecting an `i8` value.
|
||||
@@ -156,7 +156,7 @@ pub trait Deserializer {
|
||||
fn visit_i8<V>(&mut self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
self.visit(visitor)
|
||||
self.visit_i64(visitor)
|
||||
}
|
||||
|
||||
/// This method hints that the `Deserialize` type is expecting an `i16` value.
|
||||
@@ -164,7 +164,7 @@ pub trait Deserializer {
|
||||
fn visit_i16<V>(&mut self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
self.visit(visitor)
|
||||
self.visit_i64(visitor)
|
||||
}
|
||||
|
||||
/// This method hints that the `Deserialize` type is expecting an `i32` value.
|
||||
@@ -172,7 +172,7 @@ pub trait Deserializer {
|
||||
fn visit_i32<V>(&mut self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
self.visit(visitor)
|
||||
self.visit_i64(visitor)
|
||||
}
|
||||
|
||||
/// This method hints that the `Deserialize` type is expecting an `i64` value.
|
||||
@@ -188,7 +188,7 @@ pub trait Deserializer {
|
||||
fn visit_f32<V>(&mut self, visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
self.visit(visitor)
|
||||
self.visit_f64(visitor)
|
||||
}
|
||||
|
||||
/// This method hints that the `Deserialize` type is expecting a `f64` value.
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
//! leaving serde to perform roughly the same speed as a hand written serializer for a specific
|
||||
//! type.
|
||||
#![doc(html_root_url="https://serde-rs.github.io/serde/serde")]
|
||||
#![cfg_attr(feature = "nightly", feature(collections, core, enumset, nonzero, step_trait, vecmap, zero_one))]
|
||||
#![cfg_attr(feature = "nightly", feature(collections, core, enumset, nonzero, step_trait, zero_one))]
|
||||
|
||||
extern crate num;
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@ use std::collections::{
|
||||
};
|
||||
#[cfg(feature = "nightly")]
|
||||
use collections::enum_set::{CLike, EnumSet};
|
||||
#[cfg(feature = "nightly")]
|
||||
use std::collections::vec_map::VecMap;
|
||||
use std::hash::Hash;
|
||||
#[cfg(feature = "nightly")]
|
||||
use std::iter;
|
||||
@@ -558,18 +556,6 @@ impl<K, V> Serialize for HashMap<K, V>
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "nightly")]
|
||||
impl<V> Serialize for VecMap<V>
|
||||
where V: Serialize,
|
||||
{
|
||||
#[inline]
|
||||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
||||
where S: Serializer,
|
||||
{
|
||||
serializer.visit_map(MapIteratorVisitor::new(self.iter(), Some(self.len())))
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
impl<'a, T: ?Sized> Serialize for &'a T where T: Serialize {
|
||||
|
||||
@@ -95,7 +95,13 @@
|
||||
extern crate num;
|
||||
extern crate serde;
|
||||
|
||||
pub use self::de::{Deserializer, from_str};
|
||||
pub use self::de::{
|
||||
Deserializer,
|
||||
from_iter,
|
||||
from_reader,
|
||||
from_slice,
|
||||
from_str,
|
||||
};
|
||||
pub use self::error::{Error, ErrorCode, Result};
|
||||
pub use self::ser::{
|
||||
Serializer,
|
||||
|
||||
Reference in New Issue
Block a user