1use serde_derive::{Deserialize, Serialize};
4use std::borrow::Borrow;
5use std::cmp::Ordering;
6use std::hash::{Hash, Hasher};
7
8#[derive(Serialize, Deserialize, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
10#[serde(transparent)]
11#[cfg_attr(not(doc), repr(transparent))]
12pub struct UserId(pub u32);
13
14#[derive(Deserialize, Clone, Debug)]
16#[serde(deny_unknown_fields)]
17#[non_exhaustive]
18pub struct Row {
19 pub id: UserId,
21 pub gh_login: String,
22 pub name: Option<String>,
23 pub gh_avatar: String,
24 pub gh_id: i32,
25}
26
27impl Ord for Row {
28 fn cmp(&self, other: &Self) -> Ordering {
29 UserId::cmp(&self.id, &other.id)
30 }
31}
32
33impl PartialOrd for Row {
34 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
35 Some(self.cmp(other))
36 }
37}
38
39impl Eq for Row {}
40
41impl PartialEq for Row {
42 fn eq(&self, other: &Self) -> bool {
43 UserId::eq(&self.id, &other.id)
44 }
45}
46
47impl Hash for Row {
48 fn hash<H: Hasher>(&self, state: &mut H) {
49 UserId::hash(&self.id, state);
50 }
51}
52
53impl Borrow<UserId> for Row {
54 fn borrow(&self) -> &UserId {
55 &self.id
56 }
57}