Compare commits

...

8 Commits

Author SHA1 Message Date
Erick Tryzelaar cab653e7c7 Version bump 2015-08-18 12:50:39 -07:00
Erick Tryzelaar 8d999a8edd VecMap was removed from libcollections 2015-08-18 12:49:50 -07:00
Erick Tryzelaar 7b773ac088 Merge pull request #138 from erickt/master
Expose serde_json::from_{iter,reader,slice}
2015-08-13 22:32:34 -07:00
Erick Tryzelaar fc58ea7487 Expose serde_json::from_{iter,reader,slice} 2015-08-13 21:19:27 -07:00
Erick Tryzelaar c61cea0eb1 Merge pull request #136 from erickt/visit
Have deserializer numeric visits chain
2015-08-13 21:19:19 -07:00
Erick Tryzelaar 764b25bd07 Have Deserializer::visit_{usize,u8,...,isize,i8,...,f32} call visit_{u64,i64,f64}
This cuts down the amount of overloading needed by a format like
toml which wants to prevent casting a float to an integer and
vice versa.
2015-08-13 08:40:19 -07:00
Erick Tryzelaar a66cd25787 Merge pull request #135 from erickt/doc
Add a table pointing to the serializers that support serde
2015-08-11 07:02:22 -07:00
Erick Tryzelaar 0e8d94750b Add a table pointing to the serializers that support serde 2015-08-11 07:00:59 -07:00
7 changed files with 29 additions and 86 deletions
+11
View File
@@ -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
View File
@@ -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"
-60
View File
@@ -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
View File
@@ -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
View File
@@ -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;
-14
View File
@@ -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 {
+7 -1
View File
@@ -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,