db_dump/
teams.rs

1//! <b style="font-variant:small-caps">teams.csv</b>
2
3use serde_derive::{Deserialize, Serialize};
4use std::borrow::Borrow;
5use std::cmp::Ordering;
6use std::hash::{Hash, Hasher};
7
8/// Primary key of **teams.csv**.
9#[derive(Serialize, Deserialize, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
10#[serde(transparent)]
11#[cfg_attr(not(doc), repr(transparent))]
12pub struct TeamId(pub u32);
13
14/// One row of **teams.csv**.
15#[derive(Deserialize, Clone, Debug)]
16#[serde(deny_unknown_fields)]
17#[non_exhaustive]
18pub struct Row {
19    /// PRIMARY KEY
20    pub id: TeamId,
21    /// UNIQUE
22    pub login: String,
23    /// UNIQUE
24    pub github_id: u32,
25    pub name: String,
26    pub avatar: String,
27    pub org_id: Option<u32>,
28}
29
30impl Ord for Row {
31    fn cmp(&self, other: &Self) -> Ordering {
32        TeamId::cmp(&self.id, &other.id)
33    }
34}
35
36impl PartialOrd for Row {
37    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
38        Some(self.cmp(other))
39    }
40}
41
42impl Eq for Row {}
43
44impl PartialEq for Row {
45    fn eq(&self, other: &Self) -> bool {
46        TeamId::eq(&self.id, &other.id)
47    }
48}
49
50impl Hash for Row {
51    fn hash<H: Hasher>(&self, state: &mut H) {
52        TeamId::hash(&self.id, state);
53    }
54}
55
56impl Borrow<TeamId> for Row {
57    fn borrow(&self) -> &TeamId {
58        &self.id
59    }
60}