Skip to main content

github_rust/github/
types.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize)]
4pub struct GraphQLQuery<T> {
5    pub query: String,
6    pub variables: T,
7}
8
9#[derive(Deserialize)]
10pub struct GraphQLResponse<T> {
11    pub data: Option<T>,
12    pub errors: Option<Vec<GraphQLError>>,
13}
14
15#[derive(Debug, Clone, Deserialize)]
16pub struct GraphQLError {
17    pub message: String,
18    #[serde(rename = "type")]
19    pub error_type: Option<String>,
20    pub path: Option<Vec<serde_json::Value>>,
21    pub extensions: Option<serde_json::Value>,
22}
23
24#[derive(Deserialize, Serialize, Clone, Default, Debug)]
25pub struct Language {
26    pub name: String,
27    pub color: Option<String>,
28}
29
30#[derive(Deserialize, Serialize, Clone, Default, Debug)]
31pub struct License {
32    pub name: String,
33    /// Serialized as `spdxId`, retaining the shared GraphQL license format.
34    #[serde(rename = "spdxId")]
35    pub spdx_id: Option<String>,
36}
37
38#[derive(Deserialize, Serialize, Clone, Default, Debug)]
39pub struct TopicConnection {
40    pub edges: Vec<TopicEdge>,
41}
42
43#[derive(Deserialize, Serialize, Clone, Default, Debug)]
44pub struct TopicEdge {
45    pub node: TopicNode,
46}
47
48#[derive(Deserialize, Serialize, Clone, Default, Debug)]
49pub struct TopicNode {
50    pub topic: Topic,
51}
52
53#[derive(Deserialize, Serialize, Clone, Default, Debug)]
54pub struct Topic {
55    pub name: String,
56}
57
58#[derive(Deserialize, Serialize)]
59pub struct TotalCount {
60    #[serde(rename = "totalCount")]
61    pub total_count: u32,
62}
63
64#[derive(Deserialize, Serialize)]
65pub struct LanguageConnection {
66    pub edges: Vec<LanguageEdge>,
67}
68
69#[derive(Deserialize, Serialize)]
70pub struct LanguageEdge {
71    pub size: u64,
72    pub node: Language,
73}
74
75#[derive(Deserialize, Serialize)]
76pub struct Branch {
77    pub name: String,
78}
79
80/// GitHub user information
81#[derive(Deserialize, Serialize, Clone, Debug)]
82pub struct User {
83    pub login: String,
84    pub id: u64,
85    pub node_id: String,
86    pub avatar_url: String,
87    pub gravatar_id: String,
88    pub url: String,
89    pub html_url: String,
90    pub followers_url: String,
91    pub following_url: String,
92    pub gists_url: String,
93    pub starred_url: String,
94    pub subscriptions_url: String,
95    pub organizations_url: String,
96    pub repos_url: String,
97    pub events_url: String,
98    pub received_events_url: String,
99    #[serde(rename = "type")]
100    pub user_type: String,
101    pub site_admin: bool,
102}
103
104/// Stargazer with timestamp when the repository was starred
105#[derive(Deserialize, Serialize, Clone, Debug)]
106pub struct StargazerWithDate {
107    pub starred_at: String,
108    pub user: User,
109}