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(Serialize, Deserialize, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
11#[serde(transparent)]
12#[cfg_attr(not(doc), repr(transparent))]
13pub struct CrateId(pub u32);
14
15#[derive(Deserialize, Clone, Debug)]
17#[serde(deny_unknown_fields)]
18#[non_exhaustive]
19pub struct Row {
20 pub id: CrateId,
22 pub name: String,
23 #[serde(deserialize_with = "crate::datetime::de")]
24 pub updated_at: DateTime<Utc>,
25 #[serde(deserialize_with = "crate::datetime::de")]
26 pub created_at: DateTime<Utc>,
27 pub description: String,
28 pub homepage: Option<String>,
29 pub documentation: Option<String>,
30 pub readme: Option<String>,
31 pub repository: Option<String>,
32 pub max_upload_size: Option<u64>,
33 pub max_features: Option<u16>,
34}
35
36impl Ord for Row {
37 fn cmp(&self, other: &Self) -> Ordering {
38 CrateId::cmp(&self.id, &other.id)
39 }
40}
41
42impl PartialOrd for Row {
43 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
44 Some(self.cmp(other))
45 }
46}
47
48impl Eq for Row {}
49
50impl PartialEq for Row {
51 fn eq(&self, other: &Self) -> bool {
52 CrateId::eq(&self.id, &other.id)
53 }
54}
55
56impl Hash for Row {
57 fn hash<H: Hasher>(&self, state: &mut H) {
58 CrateId::hash(&self.id, state);
59 }
60}
61
62impl Borrow<CrateId> for Row {
63 fn borrow(&self) -> &CrateId {
64 &self.id
65 }
66}