mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-29 11:47:55 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ea2789df0f | |||
| b7cfe33101 | |||
| 1b8ebf6b64 | |||
| 35ad468780 | |||
| 850a29beb1 | |||
| 16bf9871cd | |||
| 6182eceed1 | |||
| 99bc52f685 | |||
| 726ff5ed31 |
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.107" # remember to update html_root_url and serde_derive dependency
|
version = "1.0.108" # remember to update html_root_url and serde_derive dependency
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "A generic serialization/deserialization framework"
|
description = "A generic serialization/deserialization framework"
|
||||||
@@ -14,7 +14,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "crates-io.md", "README.md",
|
|||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_derive = { version = "=1.0.107", optional = true, path = "../serde_derive" }
|
serde_derive = { version = "=1.0.108", optional = true, path = "../serde_derive" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_derive = { version = "1.0", path = "../serde_derive" }
|
serde_derive = { version = "1.0", path = "../serde_derive" }
|
||||||
|
|||||||
+1
-1
@@ -75,7 +75,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Serde types in rustdoc of other crates get linked to here.
|
// Serde types in rustdoc of other crates get linked to here.
|
||||||
#![doc(html_root_url = "https://docs.rs/serde/1.0.107")]
|
#![doc(html_root_url = "https://docs.rs/serde/1.0.108")]
|
||||||
// Support using Serde without the standard library!
|
// Support using Serde without the standard library!
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
// Unstable functionality only if the user asks for it. For tracking and
|
// Unstable functionality only if the user asks for it. For tracking and
|
||||||
|
|||||||
@@ -0,0 +1,174 @@
|
|||||||
|
use lib::*;
|
||||||
|
use ser::{Error, Impossible, Serialize, Serializer};
|
||||||
|
|
||||||
|
impl Error for fmt::Error {
|
||||||
|
fn custom<T: Display>(_msg: T) -> Self {
|
||||||
|
fmt::Error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! fmt_primitives {
|
||||||
|
($($f:ident: $t:ty,)*) => {
|
||||||
|
$(
|
||||||
|
fn $f(self, v: $t) -> fmt::Result {
|
||||||
|
Display::fmt(&v, self)
|
||||||
|
}
|
||||||
|
)*
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/// ```edition2018
|
||||||
|
/// use serde::Serialize;
|
||||||
|
/// use std::fmt::{self, Display};
|
||||||
|
///
|
||||||
|
/// #[derive(Serialize)]
|
||||||
|
/// #[serde(rename_all = "kebab-case")]
|
||||||
|
/// pub enum MessageType {
|
||||||
|
/// StartRequest,
|
||||||
|
/// EndRequest,
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// impl Display for MessageType {
|
||||||
|
/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
/// self.serialize(f)
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
|
||||||
|
type Ok = ();
|
||||||
|
type Error = fmt::Error;
|
||||||
|
type SerializeSeq = Impossible<(), fmt::Error>;
|
||||||
|
type SerializeTuple = Impossible<(), fmt::Error>;
|
||||||
|
type SerializeTupleStruct = Impossible<(), fmt::Error>;
|
||||||
|
type SerializeTupleVariant = Impossible<(), fmt::Error>;
|
||||||
|
type SerializeMap = Impossible<(), fmt::Error>;
|
||||||
|
type SerializeStruct = Impossible<(), fmt::Error>;
|
||||||
|
type SerializeStructVariant = Impossible<(), fmt::Error>;
|
||||||
|
|
||||||
|
fmt_primitives! {
|
||||||
|
serialize_bool: bool,
|
||||||
|
serialize_i8: i8,
|
||||||
|
serialize_i16: i16,
|
||||||
|
serialize_i32: i32,
|
||||||
|
serialize_i64: i64,
|
||||||
|
serialize_u8: u8,
|
||||||
|
serialize_u16: u16,
|
||||||
|
serialize_u32: u32,
|
||||||
|
serialize_u64: u64,
|
||||||
|
serialize_f32: f32,
|
||||||
|
serialize_f64: f64,
|
||||||
|
serialize_char: char,
|
||||||
|
serialize_str: &str,
|
||||||
|
serialize_unit_struct: &'static str,
|
||||||
|
}
|
||||||
|
|
||||||
|
serde_if_integer128! {
|
||||||
|
fmt_primitives! {
|
||||||
|
serialize_i128: i128,
|
||||||
|
serialize_u128: u128,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_unit_variant(
|
||||||
|
self,
|
||||||
|
_name: &'static str,
|
||||||
|
_variant_index: u32,
|
||||||
|
variant: &'static str,
|
||||||
|
) -> fmt::Result {
|
||||||
|
Display::fmt(variant, self)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_newtype_struct<T: ?Sized>(self, _name: &'static str, value: &T) -> fmt::Result
|
||||||
|
where
|
||||||
|
T: Serialize,
|
||||||
|
{
|
||||||
|
Serialize::serialize(value, self)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_bytes(self, _v: &[u8]) -> fmt::Result {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_none(self) -> fmt::Result {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_some<T: ?Sized>(self, _value: &T) -> fmt::Result
|
||||||
|
where
|
||||||
|
T: Serialize,
|
||||||
|
{
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_unit(self) -> fmt::Result {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_newtype_variant<T: ?Sized>(
|
||||||
|
self,
|
||||||
|
_name: &'static str,
|
||||||
|
_variant_index: u32,
|
||||||
|
_variant: &'static str,
|
||||||
|
_value: &T,
|
||||||
|
) -> fmt::Result
|
||||||
|
where
|
||||||
|
T: Serialize,
|
||||||
|
{
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq, fmt::Error> {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple, fmt::Error> {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_tuple_struct(
|
||||||
|
self,
|
||||||
|
_name: &'static str,
|
||||||
|
_len: usize,
|
||||||
|
) -> Result<Self::SerializeTupleStruct, fmt::Error> {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_tuple_variant(
|
||||||
|
self,
|
||||||
|
_name: &'static str,
|
||||||
|
_variant_index: u32,
|
||||||
|
_variant: &'static str,
|
||||||
|
_len: usize,
|
||||||
|
) -> Result<Self::SerializeTupleVariant, fmt::Error> {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_map(self, _len: Option<usize>) -> Result<Self::SerializeMap, fmt::Error> {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_struct(
|
||||||
|
self,
|
||||||
|
_name: &'static str,
|
||||||
|
_len: usize,
|
||||||
|
) -> Result<Self::SerializeStruct, fmt::Error> {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn serialize_struct_variant(
|
||||||
|
self,
|
||||||
|
_name: &'static str,
|
||||||
|
_variant_index: u32,
|
||||||
|
_variant: &'static str,
|
||||||
|
_len: usize,
|
||||||
|
) -> Result<Self::SerializeStructVariant, fmt::Error> {
|
||||||
|
Err(fmt::Error)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn collect_str<T: ?Sized>(self, value: &T) -> fmt::Result
|
||||||
|
where
|
||||||
|
T: Display,
|
||||||
|
{
|
||||||
|
Display::fmt(value, self)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -109,6 +109,7 @@
|
|||||||
|
|
||||||
use lib::*;
|
use lib::*;
|
||||||
|
|
||||||
|
mod fmt;
|
||||||
mod impls;
|
mod impls;
|
||||||
mod impossible;
|
mod impossible;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.107" # remember to update html_root_url
|
version = "1.0.108" # remember to update html_root_url
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
//!
|
//!
|
||||||
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
|
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.107")]
|
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.108")]
|
||||||
#![allow(unknown_lints, bare_trait_objects)]
|
#![allow(unknown_lints, bare_trait_objects)]
|
||||||
#![deny(clippy::all, clippy::pedantic)]
|
#![deny(clippy::all, clippy::pedantic)]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_test"
|
name = "serde_test"
|
||||||
version = "1.0.107" # remember to update html_root_url
|
version = "1.0.108" # remember to update html_root_url
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
description = "Token De/Serializer for testing De/Serialize implementations"
|
description = "Token De/Serializer for testing De/Serialize implementations"
|
||||||
|
|||||||
@@ -144,7 +144,7 @@
|
|||||||
//! # }
|
//! # }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.107")]
|
#![doc(html_root_url = "https://docs.rs/serde_test/1.0.108")]
|
||||||
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
#![cfg_attr(feature = "cargo-clippy", allow(renamed_and_removed_lints))]
|
||||||
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
#![cfg_attr(feature = "cargo-clippy", deny(clippy, clippy_pedantic))]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
|
|||||||
Reference in New Issue
Block a user