1use crate::crates::CrateId;
4use crate::versions::VersionId;
5use semver::VersionReq;
6use serde::de::{Deserialize, Deserializer, Unexpected, Visitor};
7use serde_derive::Deserialize;
8use std::fmt;
9
10#[derive(#[doc(hidden)]
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications,
clippy :: absolute_paths,)]
const _: () =
{
#[allow(unused_extern_crates, clippy :: useless_attribute)]
extern crate serde as _serde;
;
#[automatically_derived]
impl<'de> _serde::Deserialize<'de> for Row {
fn deserialize<__D>(__deserializer: __D)
-> _serde::__private228::Result<Self, __D::Error> where
__D: _serde::Deserializer<'de> {
#[allow(non_camel_case_types)]
#[doc(hidden)]
enum __Field {
__field0,
__field1,
__field2,
__field3,
__field4,
__field5,
__field6,
__field7,
__field8,
__field9,
}
#[doc(hidden)]
struct __FieldVisitor;
#[automatically_derived]
impl<'de> _serde::de::Visitor<'de> for __FieldVisitor {
type Value = __Field;
fn expecting(&self,
__formatter: &mut _serde::__private228::Formatter)
-> _serde::__private228::fmt::Result {
_serde::__private228::Formatter::write_str(__formatter,
"field identifier")
}
fn visit_u64<__E>(self, __value: u64)
-> _serde::__private228::Result<Self::Value, __E> where
__E: _serde::de::Error {
match __value {
0u64 => _serde::__private228::Ok(__Field::__field0),
1u64 => _serde::__private228::Ok(__Field::__field1),
2u64 => _serde::__private228::Ok(__Field::__field2),
3u64 => _serde::__private228::Ok(__Field::__field3),
4u64 => _serde::__private228::Ok(__Field::__field4),
5u64 => _serde::__private228::Ok(__Field::__field5),
6u64 => _serde::__private228::Ok(__Field::__field6),
7u64 => _serde::__private228::Ok(__Field::__field7),
8u64 => _serde::__private228::Ok(__Field::__field8),
9u64 => _serde::__private228::Ok(__Field::__field9),
_ =>
_serde::__private228::Err(_serde::de::Error::invalid_value(_serde::de::Unexpected::Unsigned(__value),
&"field index 0 <= i < 10")),
}
}
fn visit_str<__E>(self, __value: &str)
-> _serde::__private228::Result<Self::Value, __E> where
__E: _serde::de::Error {
match __value {
"id" => _serde::__private228::Ok(__Field::__field0),
"version_id" => _serde::__private228::Ok(__Field::__field1),
"crate_id" => _serde::__private228::Ok(__Field::__field2),
"req" => _serde::__private228::Ok(__Field::__field3),
"optional" => _serde::__private228::Ok(__Field::__field4),
"default_features" =>
_serde::__private228::Ok(__Field::__field5),
"features" => _serde::__private228::Ok(__Field::__field6),
"target" => _serde::__private228::Ok(__Field::__field7),
"kind" => _serde::__private228::Ok(__Field::__field8),
"explicit_name" =>
_serde::__private228::Ok(__Field::__field9),
_ => {
_serde::__private228::Err(_serde::de::Error::unknown_field(__value,
FIELDS))
}
}
}
fn visit_bytes<__E>(self, __value: &[u8])
-> _serde::__private228::Result<Self::Value, __E> where
__E: _serde::de::Error {
match __value {
b"id" => _serde::__private228::Ok(__Field::__field0),
b"version_id" =>
_serde::__private228::Ok(__Field::__field1),
b"crate_id" => _serde::__private228::Ok(__Field::__field2),
b"req" => _serde::__private228::Ok(__Field::__field3),
b"optional" => _serde::__private228::Ok(__Field::__field4),
b"default_features" =>
_serde::__private228::Ok(__Field::__field5),
b"features" => _serde::__private228::Ok(__Field::__field6),
b"target" => _serde::__private228::Ok(__Field::__field7),
b"kind" => _serde::__private228::Ok(__Field::__field8),
b"explicit_name" =>
_serde::__private228::Ok(__Field::__field9),
_ => {
let __value =
&_serde::__private228::from_utf8_lossy(__value);
_serde::__private228::Err(_serde::de::Error::unknown_field(__value,
FIELDS))
}
}
}
}
#[automatically_derived]
impl<'de> _serde::Deserialize<'de> for __Field {
#[inline]
fn deserialize<__D>(__deserializer: __D)
-> _serde::__private228::Result<Self, __D::Error> where
__D: _serde::Deserializer<'de> {
_serde::Deserializer::deserialize_identifier(__deserializer,
__FieldVisitor)
}
}
#[doc(hidden)]
struct __Visitor<'de> {
marker: _serde::__private228::PhantomData<Row>,
lifetime: _serde::__private228::PhantomData<&'de ()>,
}
#[automatically_derived]
impl<'de> _serde::de::Visitor<'de> for __Visitor<'de> {
type Value = Row;
fn expecting(&self,
__formatter: &mut _serde::__private228::Formatter)
-> _serde::__private228::fmt::Result {
_serde::__private228::Formatter::write_str(__formatter,
"struct Row")
}
#[inline]
fn visit_seq<__A>(self, mut __seq: __A)
-> _serde::__private228::Result<Self::Value, __A::Error>
where __A: _serde::de::SeqAccess<'de> {
let __field0 =
match _serde::de::SeqAccess::next_element::<u32>(&mut __seq)?
{
_serde::__private228::Some(__value) => __value,
_serde::__private228::None =>
return _serde::__private228::Err(_serde::de::Error::invalid_length(0usize,
&"struct Row with 10 elements")),
};
let __field1 =
match _serde::de::SeqAccess::next_element::<VersionId>(&mut __seq)?
{
_serde::__private228::Some(__value) => __value,
_serde::__private228::None =>
return _serde::__private228::Err(_serde::de::Error::invalid_length(1usize,
&"struct Row with 10 elements")),
};
let __field2 =
match _serde::de::SeqAccess::next_element::<CrateId>(&mut __seq)?
{
_serde::__private228::Some(__value) => __value,
_serde::__private228::None =>
return _serde::__private228::Err(_serde::de::Error::invalid_length(2usize,
&"struct Row with 10 elements")),
};
let __field3 =
match {
#[doc(hidden)]
struct __DeserializeWith<'de> {
value: VersionReq,
phantom: _serde::__private228::PhantomData<Row>,
lifetime: _serde::__private228::PhantomData<&'de ()>,
}
#[automatically_derived]
impl<'de> _serde::Deserialize<'de> for
__DeserializeWith<'de> {
fn deserialize<__D>(__deserializer: __D)
-> _serde::__private228::Result<Self, __D::Error> where
__D: _serde::Deserializer<'de> {
_serde::__private228::Ok(__DeserializeWith {
value: version_req(__deserializer)?,
phantom: _serde::__private228::PhantomData,
lifetime: _serde::__private228::PhantomData,
})
}
}
_serde::__private228::Option::map(_serde::de::SeqAccess::next_element::<__DeserializeWith<'de>>(&mut __seq)?,
|__wrap| __wrap.value)
} {
_serde::__private228::Some(__value) => __value,
_serde::__private228::None =>
return _serde::__private228::Err(_serde::de::Error::invalid_length(3usize,
&"struct Row with 10 elements")),
};
let __field4 =
match {
#[doc(hidden)]
struct __DeserializeWith<'de> {
value: bool,
phantom: _serde::__private228::PhantomData<Row>,
lifetime: _serde::__private228::PhantomData<&'de ()>,
}
#[automatically_derived]
impl<'de> _serde::Deserialize<'de> for
__DeserializeWith<'de> {
fn deserialize<__D>(__deserializer: __D)
-> _serde::__private228::Result<Self, __D::Error> where
__D: _serde::Deserializer<'de> {
_serde::__private228::Ok(__DeserializeWith {
value: crate::bool::de(__deserializer)?,
phantom: _serde::__private228::PhantomData,
lifetime: _serde::__private228::PhantomData,
})
}
}
_serde::__private228::Option::map(_serde::de::SeqAccess::next_element::<__DeserializeWith<'de>>(&mut __seq)?,
|__wrap| __wrap.value)
} {
_serde::__private228::Some(__value) => __value,
_serde::__private228::None =>
return _serde::__private228::Err(_serde::de::Error::invalid_length(4usize,
&"struct Row with 10 elements")),
};
let __field5 =
match {
#[doc(hidden)]
struct __DeserializeWith<'de> {
value: bool,
phantom: _serde::__private228::PhantomData<Row>,
lifetime: _serde::__private228::PhantomData<&'de ()>,
}
#[automatically_derived]
impl<'de> _serde::Deserialize<'de> for
__DeserializeWith<'de> {
fn deserialize<__D>(__deserializer: __D)
-> _serde::__private228::Result<Self, __D::Error> where
__D: _serde::Deserializer<'de> {
_serde::__private228::Ok(__DeserializeWith {
value: crate::bool::de(__deserializer)?,
phantom: _serde::__private228::PhantomData,
lifetime: _serde::__private228::PhantomData,
})
}
}
_serde::__private228::Option::map(_serde::de::SeqAccess::next_element::<__DeserializeWith<'de>>(&mut __seq)?,
|__wrap| __wrap.value)
} {
_serde::__private228::Some(__value) => __value,
_serde::__private228::None =>
return _serde::__private228::Err(_serde::de::Error::invalid_length(5usize,
&"struct Row with 10 elements")),
};
let __field6 =
match {
#[doc(hidden)]
struct __DeserializeWith<'de> {
value: Vec<String>,
phantom: _serde::__private228::PhantomData<Row>,
lifetime: _serde::__private228::PhantomData<&'de ()>,
}
#[automatically_derived]
impl<'de> _serde::Deserialize<'de> for
__DeserializeWith<'de> {
fn deserialize<__D>(__deserializer: __D)
-> _serde::__private228::Result<Self, __D::Error> where
__D: _serde::Deserializer<'de> {
_serde::__private228::Ok(__DeserializeWith {
value: features_set(__deserializer)?,
phantom: _serde::__private228::PhantomData,
lifetime: _serde::__private228::PhantomData,
})
}
}
_serde::__private228::Option::map(_serde::de::SeqAccess::next_element::<__DeserializeWith<'de>>(&mut __seq)?,
|__wrap| __wrap.value)
} {
_serde::__private228::Some(__value) => __value,
_serde::__private228::None =>
return _serde::__private228::Err(_serde::de::Error::invalid_length(6usize,
&"struct Row with 10 elements")),
};
let __field7 =
match _serde::de::SeqAccess::next_element::<String>(&mut __seq)?
{
_serde::__private228::Some(__value) => __value,
_serde::__private228::None =>
return _serde::__private228::Err(_serde::de::Error::invalid_length(7usize,
&"struct Row with 10 elements")),
};
let __field8 =
match _serde::de::SeqAccess::next_element::<DependencyKind>(&mut __seq)?
{
_serde::__private228::Some(__value) => __value,
_serde::__private228::None =>
return _serde::__private228::Err(_serde::de::Error::invalid_length(8usize,
&"struct Row with 10 elements")),
};
let __field9 =
match _serde::de::SeqAccess::next_element::<Option<String>>(&mut __seq)?
{
_serde::__private228::Some(__value) => __value,
_serde::__private228::None =>
_serde::__private228::Default::default(),
};
_serde::__private228::Ok(Row {
id: __field0,
version_id: __field1,
crate_id: __field2,
req: __field3,
optional: __field4,
default_features: __field5,
features: __field6,
target: __field7,
kind: __field8,
explicit_name: __field9,
})
}
#[inline]
fn visit_map<__A>(self, mut __map: __A)
-> _serde::__private228::Result<Self::Value, __A::Error>
where __A: _serde::de::MapAccess<'de> {
let mut __field0: _serde::__private228::Option<u32> =
_serde::__private228::None;
let mut __field1: _serde::__private228::Option<VersionId> =
_serde::__private228::None;
let mut __field2: _serde::__private228::Option<CrateId> =
_serde::__private228::None;
let mut __field3: _serde::__private228::Option<VersionReq> =
_serde::__private228::None;
let mut __field4: _serde::__private228::Option<bool> =
_serde::__private228::None;
let mut __field5: _serde::__private228::Option<bool> =
_serde::__private228::None;
let mut __field6:
_serde::__private228::Option<Vec<String>> =
_serde::__private228::None;
let mut __field7: _serde::__private228::Option<String> =
_serde::__private228::None;
let mut __field8:
_serde::__private228::Option<DependencyKind> =
_serde::__private228::None;
let mut __field9:
_serde::__private228::Option<Option<String>> =
_serde::__private228::None;
while let _serde::__private228::Some(__key) =
_serde::de::MapAccess::next_key::<__Field>(&mut __map)? {
match __key {
__Field::__field0 => {
if _serde::__private228::Option::is_some(&__field0) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("id"));
}
__field0 =
_serde::__private228::Some(_serde::de::MapAccess::next_value::<u32>(&mut __map)?);
}
__Field::__field1 => {
if _serde::__private228::Option::is_some(&__field1) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("version_id"));
}
__field1 =
_serde::__private228::Some(_serde::de::MapAccess::next_value::<VersionId>(&mut __map)?);
}
__Field::__field2 => {
if _serde::__private228::Option::is_some(&__field2) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("crate_id"));
}
__field2 =
_serde::__private228::Some(_serde::de::MapAccess::next_value::<CrateId>(&mut __map)?);
}
__Field::__field3 => {
if _serde::__private228::Option::is_some(&__field3) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("req"));
}
__field3 =
_serde::__private228::Some({
#[doc(hidden)]
struct __DeserializeWith<'de> {
value: VersionReq,
phantom: _serde::__private228::PhantomData<Row>,
lifetime: _serde::__private228::PhantomData<&'de ()>,
}
#[automatically_derived]
impl<'de> _serde::Deserialize<'de> for
__DeserializeWith<'de> {
fn deserialize<__D>(__deserializer: __D)
-> _serde::__private228::Result<Self, __D::Error> where
__D: _serde::Deserializer<'de> {
_serde::__private228::Ok(__DeserializeWith {
value: version_req(__deserializer)?,
phantom: _serde::__private228::PhantomData,
lifetime: _serde::__private228::PhantomData,
})
}
}
match _serde::de::MapAccess::next_value::<__DeserializeWith<'de>>(&mut __map)
{
_serde::__private228::Ok(__wrapper) => __wrapper.value,
_serde::__private228::Err(__err) => {
return _serde::__private228::Err(__err);
}
}
});
}
__Field::__field4 => {
if _serde::__private228::Option::is_some(&__field4) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("optional"));
}
__field4 =
_serde::__private228::Some({
#[doc(hidden)]
struct __DeserializeWith<'de> {
value: bool,
phantom: _serde::__private228::PhantomData<Row>,
lifetime: _serde::__private228::PhantomData<&'de ()>,
}
#[automatically_derived]
impl<'de> _serde::Deserialize<'de> for
__DeserializeWith<'de> {
fn deserialize<__D>(__deserializer: __D)
-> _serde::__private228::Result<Self, __D::Error> where
__D: _serde::Deserializer<'de> {
_serde::__private228::Ok(__DeserializeWith {
value: crate::bool::de(__deserializer)?,
phantom: _serde::__private228::PhantomData,
lifetime: _serde::__private228::PhantomData,
})
}
}
match _serde::de::MapAccess::next_value::<__DeserializeWith<'de>>(&mut __map)
{
_serde::__private228::Ok(__wrapper) => __wrapper.value,
_serde::__private228::Err(__err) => {
return _serde::__private228::Err(__err);
}
}
});
}
__Field::__field5 => {
if _serde::__private228::Option::is_some(&__field5) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("default_features"));
}
__field5 =
_serde::__private228::Some({
#[doc(hidden)]
struct __DeserializeWith<'de> {
value: bool,
phantom: _serde::__private228::PhantomData<Row>,
lifetime: _serde::__private228::PhantomData<&'de ()>,
}
#[automatically_derived]
impl<'de> _serde::Deserialize<'de> for
__DeserializeWith<'de> {
fn deserialize<__D>(__deserializer: __D)
-> _serde::__private228::Result<Self, __D::Error> where
__D: _serde::Deserializer<'de> {
_serde::__private228::Ok(__DeserializeWith {
value: crate::bool::de(__deserializer)?,
phantom: _serde::__private228::PhantomData,
lifetime: _serde::__private228::PhantomData,
})
}
}
match _serde::de::MapAccess::next_value::<__DeserializeWith<'de>>(&mut __map)
{
_serde::__private228::Ok(__wrapper) => __wrapper.value,
_serde::__private228::Err(__err) => {
return _serde::__private228::Err(__err);
}
}
});
}
__Field::__field6 => {
if _serde::__private228::Option::is_some(&__field6) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("features"));
}
__field6 =
_serde::__private228::Some({
#[doc(hidden)]
struct __DeserializeWith<'de> {
value: Vec<String>,
phantom: _serde::__private228::PhantomData<Row>,
lifetime: _serde::__private228::PhantomData<&'de ()>,
}
#[automatically_derived]
impl<'de> _serde::Deserialize<'de> for
__DeserializeWith<'de> {
fn deserialize<__D>(__deserializer: __D)
-> _serde::__private228::Result<Self, __D::Error> where
__D: _serde::Deserializer<'de> {
_serde::__private228::Ok(__DeserializeWith {
value: features_set(__deserializer)?,
phantom: _serde::__private228::PhantomData,
lifetime: _serde::__private228::PhantomData,
})
}
}
match _serde::de::MapAccess::next_value::<__DeserializeWith<'de>>(&mut __map)
{
_serde::__private228::Ok(__wrapper) => __wrapper.value,
_serde::__private228::Err(__err) => {
return _serde::__private228::Err(__err);
}
}
});
}
__Field::__field7 => {
if _serde::__private228::Option::is_some(&__field7) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("target"));
}
__field7 =
_serde::__private228::Some(_serde::de::MapAccess::next_value::<String>(&mut __map)?);
}
__Field::__field8 => {
if _serde::__private228::Option::is_some(&__field8) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("kind"));
}
__field8 =
_serde::__private228::Some(_serde::de::MapAccess::next_value::<DependencyKind>(&mut __map)?);
}
__Field::__field9 => {
if _serde::__private228::Option::is_some(&__field9) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("explicit_name"));
}
__field9 =
_serde::__private228::Some(_serde::de::MapAccess::next_value::<Option<String>>(&mut __map)?);
}
}
}
let __field0 =
match __field0 {
_serde::__private228::Some(__field0) => __field0,
_serde::__private228::None =>
_serde::__private228::de::missing_field("id")?,
};
let __field1 =
match __field1 {
_serde::__private228::Some(__field1) => __field1,
_serde::__private228::None =>
_serde::__private228::de::missing_field("version_id")?,
};
let __field2 =
match __field2 {
_serde::__private228::Some(__field2) => __field2,
_serde::__private228::None =>
_serde::__private228::de::missing_field("crate_id")?,
};
let __field3 =
match __field3 {
_serde::__private228::Some(__field3) => __field3,
_serde::__private228::None =>
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::missing_field("req")),
};
let __field4 =
match __field4 {
_serde::__private228::Some(__field4) => __field4,
_serde::__private228::None =>
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::missing_field("optional")),
};
let __field5 =
match __field5 {
_serde::__private228::Some(__field5) => __field5,
_serde::__private228::None =>
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::missing_field("default_features")),
};
let __field6 =
match __field6 {
_serde::__private228::Some(__field6) => __field6,
_serde::__private228::None =>
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::missing_field("features")),
};
let __field7 =
match __field7 {
_serde::__private228::Some(__field7) => __field7,
_serde::__private228::None =>
_serde::__private228::de::missing_field("target")?,
};
let __field8 =
match __field8 {
_serde::__private228::Some(__field8) => __field8,
_serde::__private228::None =>
_serde::__private228::de::missing_field("kind")?,
};
let __field9 =
match __field9 {
_serde::__private228::Some(__field9) => __field9,
_serde::__private228::None =>
_serde::__private228::Default::default(),
};
_serde::__private228::Ok(Row {
id: __field0,
version_id: __field1,
crate_id: __field2,
req: __field3,
optional: __field4,
default_features: __field5,
features: __field6,
target: __field7,
kind: __field8,
explicit_name: __field9,
})
}
}
#[doc(hidden)]
const FIELDS: &'static [&'static str] =
&["id", "version_id", "crate_id", "req", "optional",
"default_features", "features", "target", "kind",
"explicit_name"];
_serde::Deserializer::deserialize_struct(__deserializer,
"Row", FIELDS,
__Visitor {
marker: _serde::__private228::PhantomData::<Row>,
lifetime: _serde::__private228::PhantomData,
})
}
}
};Deserialize, #[automatically_derived]
impl ::core::clone::Clone for Row {
#[inline]
fn clone(&self) -> Row {
Row {
id: ::core::clone::Clone::clone(&self.id),
version_id: ::core::clone::Clone::clone(&self.version_id),
crate_id: ::core::clone::Clone::clone(&self.crate_id),
req: ::core::clone::Clone::clone(&self.req),
optional: ::core::clone::Clone::clone(&self.optional),
default_features: ::core::clone::Clone::clone(&self.default_features),
features: ::core::clone::Clone::clone(&self.features),
target: ::core::clone::Clone::clone(&self.target),
kind: ::core::clone::Clone::clone(&self.kind),
explicit_name: ::core::clone::Clone::clone(&self.explicit_name),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Row {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
let names: &'static _ =
&["id", "version_id", "crate_id", "req", "optional",
"default_features", "features", "target", "kind",
"explicit_name"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.id, &self.version_id, &self.crate_id, &self.req,
&self.optional, &self.default_features, &self.features,
&self.target, &self.kind, &&self.explicit_name];
::core::fmt::Formatter::debug_struct_fields_finish(f, "Row", names,
values)
}
}Debug)]
12#[serde(deny_unknown_fields)]
13#[non_exhaustive]
14pub struct Row {
15 pub id: u32,
17 pub version_id: VersionId,
18 pub crate_id: CrateId,
19 #[serde(deserialize_with = "version_req")]
20 pub req: VersionReq,
21 #[serde(deserialize_with = "crate::bool::de")]
22 pub optional: bool,
23 #[serde(deserialize_with = "crate::bool::de")]
24 pub default_features: bool,
25 #[serde(deserialize_with = "features_set")]
26 pub features: Vec<String>,
27 pub target: String,
28 pub kind: DependencyKind,
29 #[serde(default)]
30 pub explicit_name: Option<String>,
31}
32
33#[derive(#[automatically_derived]
impl ::core::marker::Copy for DependencyKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for DependencyKind {
#[inline]
fn clone(&self) -> DependencyKind { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for DependencyKind {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f,
match self {
DependencyKind::Normal => "Normal",
DependencyKind::Build => "Build",
DependencyKind::Dev => "Dev",
})
}
}Debug)]
34pub enum DependencyKind {
35 Normal,
37 Build,
39 Dev,
41}
42
43struct DependencyKindVisitor;
44
45impl<'de> Visitor<'de> for DependencyKindVisitor {
46 type Value = DependencyKind;
47
48 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
49 formatter.write_str("dependency kind (0, 1, 2)")
50 }
51
52 fn visit_u8<E>(self, kind: u8) -> Result<Self::Value, E>
53 where
54 E: serde::de::Error,
55 {
56 match kind {
57 0 => Ok(DependencyKind::Normal),
58 1 => Ok(DependencyKind::Build),
59 2 => Ok(DependencyKind::Dev),
60 _ => Err(serde::de::Error::invalid_value(
61 Unexpected::Unsigned(kind as u64),
62 &self,
63 )),
64 }
65 }
66}
67
68impl<'de> Deserialize<'de> for DependencyKind {
69 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
70 where
71 D: Deserializer<'de>,
72 {
73 deserializer.deserialize_u8(DependencyKindVisitor)
74 }
75}
76
77fn compat(string: &str) -> Option<VersionReq> {
78 let deprecated = match string {
79 "^0-.11.0" => "^0.11.0",
80 "^0.1-alpha.0" => "^0.1.0-alpha.0",
81 "^0.51-oldsyn" => "^0.51.1-oldsyn",
82 "~2.0-2.2" => ">=2.0, <=2.2",
83 _ => return None,
84 };
85 Some(deprecated.parse().unwrap())
86}
87
88struct VersionReqVisitor;
89
90impl<'de> Visitor<'de> for VersionReqVisitor {
91 type Value = VersionReq;
92
93 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
94 formatter.write_str("semver version req")
95 }
96
97 fn visit_str<E>(self, string: &str) -> Result<Self::Value, E>
98 where
99 E: serde::de::Error,
100 {
101 match string.parse() {
102 Ok(version) => Ok(version),
103 Err(err) => {
104 if let Some(version) = compat(string) {
105 Ok(version)
106 } else {
107 Err(serde::de::Error::custom(format_args!("{0}: req {1}", err, string)format_args!(
108 "{}: req {}",
109 err, string,
110 )))
111 }
112 }
113 }
114 }
115}
116
117fn version_req<'de, D>(deserializer: D) -> Result<VersionReq, D::Error>
118where
119 D: Deserializer<'de>,
120{
121 deserializer.deserialize_str(VersionReqVisitor)
122}
123
124fn features_set<'de, D>(deserializer: D) -> Result<Vec<String>, D::Error>
125where
126 D: Deserializer<'de>,
127{
128 crate::set::de(deserializer, "features set")
129}