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 KeywordId {
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 KeywordId {
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| KeywordId { 0: __transparent })
}
}
};Deserialize, #[automatically_derived]
impl ::core::marker::Copy for KeywordId { }Copy, #[automatically_derived]
impl ::core::clone::Clone for KeywordId {
#[inline]
fn clone(&self) -> KeywordId {
let _: ::core::clone::AssertParamIsClone<u32>;
*self
}
}Clone, #[automatically_derived]
impl ::core::cmp::Ord for KeywordId {
#[inline]
fn cmp(&self, other: &KeywordId) -> ::core::cmp::Ordering {
::core::cmp::Ord::cmp(&self.0, &other.0)
}
}Ord, #[automatically_derived]
impl ::core::cmp::PartialOrd for KeywordId {
#[inline]
fn partial_cmp(&self, other: &KeywordId)
-> ::core::option::Option<::core::cmp::Ordering> {
::core::cmp::PartialOrd::partial_cmp(&self.0, &other.0)
}
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Eq for KeywordId {
#[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 KeywordId {
#[inline]
fn eq(&self, other: &KeywordId) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl ::core::hash::Hash for KeywordId {
#[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 KeywordId {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f, "KeywordId",
&&self.0)
}
}Debug)]
11#[serde(transparent)]
12#[cfg_attr(not(doc), repr(transparent))]
13pub struct KeywordId(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, }
#[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),
_ =>
_serde::__private228::Err(_serde::de::Error::invalid_value(_serde::de::Unexpected::Unsigned(__value),
&"field index 0 <= i < 4")),
}
}
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),
"keyword" => _serde::__private228::Ok(__Field::__field1),
"crates_cnt" => _serde::__private228::Ok(__Field::__field2),
"created_at" => _serde::__private228::Ok(__Field::__field3),
_ => {
_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"keyword" => _serde::__private228::Ok(__Field::__field1),
b"crates_cnt" =>
_serde::__private228::Ok(__Field::__field2),
b"created_at" =>
_serde::__private228::Ok(__Field::__field3),
_ => {
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::<KeywordId>(&mut __seq)?
{
_serde::__private228::Some(__value) => __value,
_serde::__private228::None =>
return _serde::__private228::Err(_serde::de::Error::invalid_length(0usize,
&"struct Row with 4 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 4 elements")),
};
let __field2 =
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(2usize,
&"struct Row with 4 elements")),
};
let __field3 =
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(3usize,
&"struct Row with 4 elements")),
};
_serde::__private228::Ok(Row {
id: __field0,
keyword: __field1,
crates_cnt: __field2,
created_at: __field3,
})
}
#[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<KeywordId> =
_serde::__private228::None;
let mut __field1: _serde::__private228::Option<String> =
_serde::__private228::None;
let mut __field2: _serde::__private228::Option<u32> =
_serde::__private228::None;
let mut __field3:
_serde::__private228::Option<DateTime<Utc>> =
_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::<KeywordId>(&mut __map)?);
}
__Field::__field1 => {
if _serde::__private228::Option::is_some(&__field1) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("keyword"));
}
__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("crates_cnt"));
}
__field2 =
_serde::__private228::Some(_serde::de::MapAccess::next_value::<u32>(&mut __map)?);
}
__Field::__field3 => {
if _serde::__private228::Option::is_some(&__field3) {
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::duplicate_field("created_at"));
}
__field3 =
_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);
}
}
});
}
}
}
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("keyword")?,
};
let __field2 =
match __field2 {
_serde::__private228::Some(__field2) => __field2,
_serde::__private228::None =>
_serde::__private228::de::missing_field("crates_cnt")?,
};
let __field3 =
match __field3 {
_serde::__private228::Some(__field3) => __field3,
_serde::__private228::None =>
return _serde::__private228::Err(<__A::Error as
_serde::de::Error>::missing_field("created_at")),
};
_serde::__private228::Ok(Row {
id: __field0,
keyword: __field1,
crates_cnt: __field2,
created_at: __field3,
})
}
}
#[doc(hidden)]
const FIELDS: &'static [&'static str] =
&["id", "keyword", "crates_cnt", "created_at"];
_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),
keyword: ::core::clone::Clone::clone(&self.keyword),
crates_cnt: ::core::clone::Clone::clone(&self.crates_cnt),
created_at: ::core::clone::Clone::clone(&self.created_at),
}
}
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Row {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field4_finish(f, "Row", "id",
&self.id, "keyword", &self.keyword, "crates_cnt",
&self.crates_cnt, "created_at", &&self.created_at)
}
}Debug)]
17#[serde(deny_unknown_fields)]
18#[non_exhaustive]
19pub struct Row {
20 pub id: KeywordId,
22 pub keyword: String,
24 pub crates_cnt: u32,
25 #[serde(deserialize_with = "crate::datetime::de")]
26 pub created_at: DateTime<Utc>,
27}
28
29impl Ord for Row {
30 fn cmp(&self, other: &Self) -> Ordering {
31 KeywordId::cmp(&self.id, &other.id)
32 }
33}
34
35impl PartialOrd for Row {
36 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
37 Some(self.cmp(other))
38 }
39}
40
41impl Eq for Row {}
42
43impl PartialEq for Row {
44 fn eq(&self, other: &Self) -> bool {
45 KeywordId::eq(&self.id, &other.id)
46 }
47}
48
49impl Hash for Row {
50 fn hash<H: Hasher>(&self, state: &mut H) {
51 KeywordId::hash(&self.id, state);
52 }
53}
54
55impl Borrow<KeywordId> for Row {
56 fn borrow(&self) -> &KeywordId {
57 &self.id
58 }
59}