1use chrono::{DateTime, Utc};
4use serde_derive::{Deserialize, Serialize};
5use std::borrow::Borrow;
6use std::cmp::Ordering;
7use std::hash::{Hash, Hasher};
8
9#[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 _serde::Serialize for CategoryId {
fn serialize<__S>(&self, __serializer: __S)
-> _serde::__private228::Result<__S::Ok, __S::Error> where
__S: _serde::Serializer {
_serde::Serialize::serialize(&self.0, __serializer)
}
}
};Serialize, #[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 CategoryId {
fn deserialize<__D>(__deserializer: __D)
-> _serde::__private228::Result<Self, __D::Error> where
__D: _serde::Deserializer<'de> {
_serde::__private228::Result::map(_serde::Deserialize::deserialize(__deserializer),
|__transparent| CategoryId { 0: __transparent })
}
}
};Deserialize, #[automatically_derived]
impl ::core::marker::Copy for CategoryId { }Copy, #[automatically_derived]
impl ::core::clone::Clone for CategoryId {
#[inline]
fn clone(&self) -> CategoryId {
let _: ::core::clone::AssertParamIsClone<u32>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::Ord for CategoryId {
#[inline]
fn cmp(&self, other: &CategoryId) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&self.0, &other.0)
}
}Ord, #[automatically_derived]
impl ::core::cmp::PartialOrd for CategoryId {
#[inline]
fn partial_cmp(&self, other: &CategoryId)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Eq for CategoryId {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_receiver_is_total_eq(&self) -> () {
let _: ::core::cmp::AssertParamIsEq<u32>;
}
}Eq, #[automatically_derived]
impl ::core::cmp::PartialEq for CategoryId {
#[inline]
fn eq(&self, other: &CategoryId) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for CategoryId {
#[inline]
fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) -> () {
::core::hash::Hash::hash(&self.0, state)
}
}Hash, #[automatically_derived]
impl ::core::fmt::Debug for CategoryId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f, "CategoryId",
&&self.0)
}
}Debug)]
11#[serde(transparent)]
12#[cfg_attr(not(doc), repr(transparent))]
13pub struct CategoryId(pub u32);
14
15#[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,
}
#[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),
_ =>
_serde::__private228::Err(_serde::de::Error::invalid_value(_serde::de::Unexpected::Unsigned(__value),
&"field index 0 <= i < 7")),
}
}
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),
"category" => _serde::__private228::Ok(__Field::__field1),
"slug" => _serde::__private228::Ok(__Field::__field2),
"description" =>
_serde::__private228::Ok(__Field::__field3),
"crates_cnt" => _serde::__private228::Ok(__Field::__field4),
"created_at" => _serde::__private228::Ok(__Field::__field5),
"path" => _serde::__private228::Ok(__Field::__field6),
_ => {
_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"category" => _serde::__private228::Ok(__Field::__field1),
b"slug" => _serde::__private228::Ok(__Field::__field2),
b"description" =>
_serde::__private228::Ok(__Field::__field3),
b"crates_cnt" =>
_serde::__private228::Ok(__Field::__field4),
b"created_at" =>
_serde::__private228::Ok(__Field::__field5),
b"path" => _serde::__private228::Ok(__Field::__field6),
_ => {
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::<CategoryId>(&mut __seq)?
{
_serde::__private228::Some(__value) => __value,
_serde::__private228::None =>
return _serde::__private228::Err(_serde::de::Error::invalid_length(0usize,
&"struct Row with 7 elements")),
};
let __field1 =
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(1usize,
&"struct Row with 7 elements")),
};
let __field2 =
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(2usize,
&"struct Row with 7 elements")),
};
let __field3 =
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(3usize,
&"struct Row with 7 elements")),
};
let __field4 =
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(4usize,
&"struct Row with 7 elements")),
};
let __field5 =
match {
#[doc(hidden)]
struct __DeserializeWith<'de> {
value: DateTime<Utc>,
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::datetime::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 7 elements")),
};
let __field6 =
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(6usize,
&"struct Row with 7 elements")),
};
_serde::__private228::Ok(Row {
id: __field0,
category: __field1,
slug: __field2,
description: __field3,
crates_cnt: __field4,
created_at: __field5,
path: __field6,
})
}
#[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<CategoryId> =
_serde::__private228::None;
let mut __field1: _serde::__private228::Option<String> =
_serde::__private228::None;
let mut __field2: _serde::__private228::Option<String> =
_serde::__private228::None;
let mut __field3: _serde::__private228::Option<String> =
_serde::__private228::None;
let mut __field4: _serde::__private228::Option<u32> =
_serde::__private228::None;
let mut __field5:
_serde::__private228::Option<DateTime<Utc>> =
_serde::__private228::None;
let mut __field6: _serde::__private228::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::<CategoryId>(&mut __map)?);
}
__Field::__field1 => {
if _serde::__private228::Option::is_some(&__field1) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("category"));
}
__field1 =
_serde::__private228::Some(_serde::de::MapAccess::next_value::<String>(&mut __map)?);
}
__Field::__field2 => {
if _serde::__private228::Option::is_some(&__field2) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("slug"));
}
__field2 =
_serde::__private228::Some(_serde::de::MapAccess::next_value::<String>(&mut __map)?);
}
__Field::__field3 => {
if _serde::__private228::Option::is_some(&__field3) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("description"));
}
__field3 =
_serde::__private228::Some(_serde::de::MapAccess::next_value::<String>(&mut __map)?);
}
__Field::__field4 => {
if _serde::__private228::Option::is_some(&__field4) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("crates_cnt"));
}
__field4 =
_serde::__private228::Some(_serde::de::MapAccess::next_value::<u32>(&mut __map)?);
}
__Field::__field5 => {
if _serde::__private228::Option::is_some(&__field5) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("created_at"));
}
__field5 =
_serde::__private228::Some({
#[doc(hidden)]
struct __DeserializeWith<'de> {
value: DateTime<Utc>,
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::datetime::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("path"));
}
__field6 =
_serde::__private228::Some(_serde::de::MapAccess::next_value::<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("category")?,
};
let __field2 =
match __field2 {
_serde::__private228::Some(__field2) => __field2,
_serde::__private228::None =>
_serde::__private228::de::missing_field("slug")?,
};
let __field3 =
match __field3 {
_serde::__private228::Some(__field3) => __field3,
_serde::__private228::None =>
_serde::__private228::de::missing_field("description")?,
};
let __field4 =
match __field4 {
_serde::__private228::Some(__field4) => __field4,
_serde::__private228::None =>
_serde::__private228::de::missing_field("crates_cnt")?,
};
let __field5 =
match __field5 {
_serde::__private228::Some(__field5) => __field5,
_serde::__private228::None =>
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::missing_field("created_at")),
};
let __field6 =
match __field6 {
_serde::__private228::Some(__field6) => __field6,
_serde::__private228::None =>
_serde::__private228::de::missing_field("path")?,
};
_serde::__private228::Ok(Row {
id: __field0,
category: __field1,
slug: __field2,
description: __field3,
crates_cnt: __field4,
created_at: __field5,
path: __field6,
})
}
}
#[doc(hidden)]
const FIELDS: &'static [&'static str] =
&["id", "category", "slug", "description", "crates_cnt",
"created_at", "path"];
_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),
category: ::core::clone::Clone::clone(&self.category),
slug: ::core::clone::Clone::clone(&self.slug),
description: ::core::clone::Clone::clone(&self.description),
crates_cnt: ::core::clone::Clone::clone(&self.crates_cnt),
created_at: ::core::clone::Clone::clone(&self.created_at),
path: ::core::clone::Clone::clone(&self.path),
}
}
}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", "category", "slug", "description", "crates_cnt",
"created_at", "path"];
let values: &[&dyn ::core::fmt::Debug] =
&[&self.id, &self.category, &self.slug, &self.description,
&self.crates_cnt, &self.created_at, &&self.path];
::core::fmt::Formatter::debug_struct_fields_finish(f, "Row", names,
values)
}
}Debug)]
17#[serde(deny_unknown_fields)]
18#[non_exhaustive]
19pub struct Row {
20 pub id: CategoryId,
22 pub category: String,
24 pub slug: String,
26 pub description: String,
27 pub crates_cnt: u32,
28 #[serde(deserialize_with = "crate::datetime::de")]
29 pub created_at: DateTime<Utc>,
30 pub path: String,
31}
32
33impl Ord for Row {
34 fn cmp(&self, other: &Self) -> Ordering {
35 CategoryId::cmp(&self.id, &other.id)
36 }
37}
38
39impl PartialOrd for Row {
40 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
41 Some(self.cmp(other))
42 }
43}
44
45impl Eq for Row {}
46
47impl PartialEq for Row {
48 fn eq(&self, other: &Self) -> bool {
49 CategoryId::eq(&self.id, &other.id)
50 }
51}
52
53impl Hash for Row {
54 fn hash<H: Hasher>(&self, state: &mut H) {
55 CategoryId::hash(&self.id, state);
56 }
57}
58
59impl Borrow<CategoryId> for Row {
60 fn borrow(&self) -> &CategoryId {
61 &self.id
62 }
63}