Skip to content

Commit c1d73b3

Browse files
committed
Replace serde with serde_core in all files
Rename Cargo.toml dependency, features, and rust imports. Replace references to `serde_with::serde` with `serde_with::__private__` in all files. Perform the same replacement for `core` crate. Remove references to `serde` crate if possible, i.e., due to existing prelude imports. Bump serde_json to a version with serde_core support.
1 parent 320d292 commit c1d73b3

File tree

12 files changed

+60
-49
lines changed

12 files changed

+60
-49
lines changed

Cargo.lock

Lines changed: 18 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

serde_with/Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ default = ["std", "macros"]
3737
#! Some features require `alloc` or `std` support and might not work in a `no_std` environment.
3838

3939
## Enable support for types from the `alloc` crate when running in a `no_std` environment.
40-
alloc = ["serde/alloc", "base64?/alloc", "chrono_0_4?/alloc", "hex?/alloc", "serde_json?/alloc", "time_0_3?/alloc"]
40+
alloc = ["serde_core/alloc", "base64?/alloc", "chrono_0_4?/alloc", "hex?/alloc", "serde_json?/alloc", "time_0_3?/alloc"]
4141
## Enables support for various types from the std library.
4242
## This will enable `std` support in all dependencies too.
4343
## The feature enabled by default and also enables `alloc`.
44-
std = ["alloc", "serde/std", "chrono_0_4?/clock", "chrono_0_4?/std", "indexmap_1?/std", "indexmap_2?/std", "time_0_3?/serde-well-known", "time_0_3?/std", "schemars_0_9?/std", "schemars_1?/std"]
44+
std = ["alloc", "serde_core/std", "chrono_0_4?/clock", "chrono_0_4?/std", "indexmap_1?/std", "indexmap_2?/std", "time_0_3?/serde-well-known", "time_0_3?/std", "schemars_0_9?/std", "schemars_1?/std"]
4545

4646
#! # Documentation
4747
#!
@@ -161,8 +161,8 @@ indexmap_2 = { package = "indexmap", version = "2.0", optional = true, default-f
161161
schemars_0_8 = { package = "schemars", version = "0.8.16", optional = true, default-features = false }
162162
schemars_0_9 = { package = "schemars", version = "0.9.0", optional = true, default-features = false }
163163
schemars_1 = { package = "schemars", version = "1.0.2", optional = true, default-features = false }
164-
serde = { version = "1.0.152", default-features = false }
165-
serde_json = { version = "1.0.45", optional = true, default-features = false }
164+
serde_core = { version = "1.0.225", default-features = false, features = ["result"] }
165+
serde_json = { version = "1.0.145", optional = true, default-features = false }
166166
serde_with_macros = { path = "../serde_with_macros", version = "=3.14.1", optional = true }
167167
time_0_3 = { package = "time", version = "~0.3.36", optional = true, default-features = false }
168168

serde_with/src/content/de.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ where
380380
let seq = content
381381
.into_iter()
382382
.map(|x| ContentDeserializer::new(x, is_human_readable));
383-
let mut seq_visitor = serde::de::value::SeqDeserializer::new(seq);
383+
let mut seq_visitor = serde_core::de::value::SeqDeserializer::new(seq);
384384
let value = visitor.visit_seq(&mut seq_visitor)?;
385385
seq_visitor.end()?;
386386
Ok(value)
@@ -401,7 +401,7 @@ where
401401
ContentDeserializer::new(v, is_human_readable),
402402
)
403403
});
404-
let mut map_visitor = serde::de::value::MapDeserializer::new(map);
404+
let mut map_visitor = serde_core::de::value::MapDeserializer::new(map);
405405
let value = visitor.visit_map(&mut map_visitor)?;
406406
map_visitor.end()?;
407407
Ok(value)
@@ -1201,7 +1201,7 @@ where
12011201
let seq = content
12021202
.iter()
12031203
.map(|x| ContentRefDeserializer::new(x, is_human_readable));
1204-
let mut seq_visitor = serde::de::value::SeqDeserializer::new(seq);
1204+
let mut seq_visitor = serde_core::de::value::SeqDeserializer::new(seq);
12051205
let value = visitor.visit_seq(&mut seq_visitor)?;
12061206
seq_visitor.end()?;
12071207
Ok(value)
@@ -1222,7 +1222,7 @@ where
12221222
ContentRefDeserializer::new(v, is_human_readable),
12231223
)
12241224
});
1225-
let mut map_visitor = serde::de::value::MapDeserializer::new(map);
1225+
let mut map_visitor = serde_core::de::value::MapDeserializer::new(map);
12261226
let value = visitor.visit_map(&mut map_visitor)?;
12271227
map_visitor.end()?;
12281228
Ok(value)

serde_with/src/enum_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ where
733733
self.deserialize_seq(visitor)
734734
}
735735

736-
serde::forward_to_deserialize_any! {
736+
forward_to_deserialize_any! {
737737
bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
738738
bytes byte_buf option unit unit_struct newtype_struct tuple
739739
tuple_struct map struct enum identifier ignored_any
@@ -815,7 +815,7 @@ where
815815
visitor.visit_enum(self)
816816
}
817817

818-
serde::forward_to_deserialize_any! {
818+
forward_to_deserialize_any! {
819819
bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
820820
bytes byte_buf option unit unit_struct newtype_struct seq tuple
821821
tuple_struct map struct identifier ignored_any

serde_with/src/flatten_maybe.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ macro_rules! flattened_maybe {
5757
($fn:ident, $field:tt) => {
5858
fn $fn<'de, T, D>(deserializer: D) -> $crate::__private__::Result<T, D::Error>
5959
where
60-
T: $crate::serde::Deserialize<'de>,
61-
D: $crate::serde::Deserializer<'de>,
60+
T: $crate::__private__::Deserialize<'de>,
61+
D: $crate::__private__::Deserializer<'de>,
6262
{
63-
$crate::serde::de::DeserializeSeed::deserialize(
63+
$crate::__private__::DeserializeSeed::deserialize(
6464
$crate::flatten_maybe::FlattenedMaybe($field, $crate::__private__::PhantomData),
6565
deserializer,
6666
)
@@ -73,7 +73,7 @@ macro_rules! flattened_maybe {
7373
/// Takes as first value the field name of the non-flattened field.
7474
pub struct FlattenedMaybe<T>(pub &'static str, pub PhantomData<T>);
7575

76-
impl<'de, T> serde::de::DeserializeSeed<'de> for FlattenedMaybe<T>
76+
impl<'de, T> DeserializeSeed<'de> for FlattenedMaybe<T>
7777
where
7878
T: Deserialize<'de>,
7979
{

serde_with/src/key_value_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ where
923923
self.deserialize_seq(visitor)
924924
}
925925

926-
serde::forward_to_deserialize_any! {
926+
forward_to_deserialize_any! {
927927
bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
928928
bytes byte_buf option unit unit_struct newtype_struct tuple
929929
tuple_struct map struct enum identifier ignored_any
@@ -1047,7 +1047,7 @@ where
10471047
})
10481048
}
10491049

1050-
serde::forward_to_deserialize_any! {
1050+
forward_to_deserialize_any! {
10511051
bool i8 i16 i32 i64 i128 u8 u16 u32 u64 u128 f32 f64 char str string
10521052
bytes byte_buf option unit unit_struct newtype_struct
10531053
enum identifier ignored_any
@@ -1246,7 +1246,7 @@ where
12461246
K: DeserializeSeed<'de>,
12471247
{
12481248
if self.first.is_some() {
1249-
seed.deserialize(serde::de::value::StringDeserializer::new(
1249+
seed.deserialize(serde_core::de::value::StringDeserializer::new(
12501250
MAP_KEY_IDENTIFIER.to_string(),
12511251
))
12521252
.map(Some)

serde_with/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@
266266
#[cfg(feature = "alloc")]
267267
extern crate alloc;
268268
#[doc(hidden)]
269-
pub extern crate core;
269+
extern crate core;
270270
#[doc(hidden)]
271-
pub extern crate serde;
271+
extern crate serde_core;
272272
#[cfg(feature = "std")]
273273
extern crate std;
274274

@@ -402,10 +402,10 @@ pub(crate) mod prelude {
402402
option::Option,
403403
pin::Pin,
404404
result::Result,
405-
str::FromStr,
405+
str::{self, FromStr},
406406
time::Duration,
407407
};
408-
pub use serde::{
408+
pub use serde_core::{
409409
de::{
410410
Deserialize, DeserializeOwned, DeserializeSeed, Deserializer, EnumAccess,
411411
Error as DeError, Expected, IgnoredAny, IntoDeserializer, MapAccess, SeqAccess,
@@ -2192,12 +2192,12 @@ pub struct BorrowCow;
21922192
#[cfg(feature = "alloc")]
21932193
pub trait InspectError {
21942194
/// Inspect a deserialization error which was skipped.
2195-
fn inspect_error(error: impl serde::de::Error);
2195+
fn inspect_error(error: impl serde_core::de::Error);
21962196
}
21972197

21982198
#[cfg(feature = "alloc")]
21992199
impl InspectError for () {
2200-
fn inspect_error(_error: impl serde::de::Error) {}
2200+
fn inspect_error(_error: impl serde_core::de::Error) {}
22012201
}
22022202

22032203
/// Deserialize a sequence into `Vec<T>`, skipping elements which fail to deserialize.

serde_with/src/ser/impls.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ macro_rules! tuple_impl {
467467
where
468468
S: Serializer,
469469
{
470-
use serde::ser::SerializeTuple;
471470
let mut tup = serializer.serialize_tuple($len)?;
472471
$(
473472
tup.serialize_element(&SerializeAsWrap::<$t, $tas>::new(&tuple.$n))?;

serde_with/src/serde_conv.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,25 +120,25 @@ macro_rules! serde_conv {
120120
impl $m {
121121
$vis fn serialize<S>(x: &$t, serializer: S) -> $crate::__private__::Result<S::Ok, S::Error>
122122
where
123-
S: $crate::serde::Serializer,
123+
S: $crate::__private__::Serializer,
124124
{
125125
let y = $ser(x);
126-
$crate::serde::Serialize::serialize(&y, serializer)
126+
$crate::__private__::Serialize::serialize(&y, serializer)
127127
}
128128

129129
$vis fn deserialize<'de, D>(deserializer: D) -> $crate::__private__::Result<$t, D::Error>
130130
where
131-
D: $crate::serde::Deserializer<'de>,
131+
D: $crate::__private__::Deserializer<'de>,
132132
{
133-
let y = $crate::serde::Deserialize::deserialize(deserializer)?;
134-
$de(y).map_err($crate::serde::de::Error::custom)
133+
let y = $crate::__private__::Deserialize::deserialize(deserializer)?;
134+
$de(y).map_err($crate::__private__::DeError::custom)
135135
}
136136
}
137137

138138
impl $crate::SerializeAs<$t> for $m {
139139
fn serialize_as<S>(x: &$t, serializer: S) -> $crate::__private__::Result<S::Ok, S::Error>
140140
where
141-
S: $crate::serde::Serializer,
141+
S: $crate::__private__::Serializer,
142142
{
143143
Self::serialize(x, serializer)
144144
}
@@ -147,7 +147,7 @@ macro_rules! serde_conv {
147147
impl<'de> $crate::DeserializeAs<'de, $t> for $m {
148148
fn deserialize_as<D>(deserializer: D) -> $crate::__private__::Result<$t, D::Error>
149149
where
150-
D: $crate::serde::Deserializer<'de>,
150+
D: $crate::__private__::Deserializer<'de>,
151151
{
152152
Self::deserialize(deserializer)
153153
}

serde_with/src/with_prefix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ macro_rules! with_prefix {
105105
($module:ident $prefix:expr) => {$crate::with_prefix!(pub(self) $module $prefix);};
106106
($vis:vis $module:ident $prefix:expr) => {
107107
$vis mod $module {
108-
use $crate::serde::{Deserialize, Deserializer, Serialize, Serializer};
108+
use $crate::__private__::{Deserialize, Deserializer, Serialize, Serializer};
109109
use $crate::with_prefix::WithPrefix;
110110

111111
#[allow(dead_code)]

0 commit comments

Comments
 (0)