summaryrefslogtreecommitdiff
path: root/src/types.rs
diff options
context:
space:
mode:
authorpennae <github@quasiparticle.net>2022-05-28 15:14:52 +0200
committerpennae <github@quasiparticle.net>2022-06-01 01:45:18 +0200
commit50068653801991e67487f1b555b83f9232a3bd48 (patch)
tree229f7427e4cadbe3e9fbdee3c07a622fa59fb54b /src/types.rs
downloadlabel-tracker-50068653801991e67487f1b555b83f9232a3bd48.tar.gz
label-tracker-50068653801991e67487f1b555b83f9232a3bd48.tar.xz
label-tracker-50068653801991e67487f1b555b83f9232a3bd48.zip
initial commit
Diffstat (limited to 'src/types.rs')
-rw-r--r--src/types.rs72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/types.rs b/src/types.rs
new file mode 100644
index 0000000..a960647
--- /dev/null
+++ b/src/types.rs
@@ -0,0 +1,72 @@
+#![allow(non_camel_case_types)]
+
+use std::collections::BTreeMap;
+
+use serde::{Deserialize, Serialize};
+
+pub type DateTime = chrono::DateTime<chrono::Utc>;
+#[allow(clippy::upper_case_acronyms)]
+pub type HTML = String;
+#[allow(clippy::upper_case_acronyms)]
+pub type URI = String;
+
+pub const STATE_VERSION: u32 = 1;
+
+#[derive(Default, Debug, Serialize, Deserialize)]
+#[serde(deny_unknown_fields)]
+pub struct State {
+ pub version: u32,
+ pub owner: String,
+ pub repo: String,
+ pub label: String,
+ pub issues_updated: Option<DateTime>,
+ pub issues: BTreeMap<String, Issue>,
+ pub issue_history: Vec<(DateTime, String, IssueAction)>,
+ pub pull_requests_updated: Option<DateTime>,
+ pub pull_requests: BTreeMap<String, PullRequest>,
+ pub pull_history: Vec<(DateTime, String, PullAction)>,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(deny_unknown_fields)]
+pub struct Issue {
+ #[serde(skip)]
+ pub id: String,
+ pub title: String,
+ pub is_open: bool,
+ pub body: String,
+ pub last_update: DateTime,
+ pub url: String,
+}
+
+#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
+#[serde(deny_unknown_fields)]
+pub enum IssueAction {
+ New,
+ Closed,
+ NewClosed,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(deny_unknown_fields)]
+pub struct PullRequest {
+ #[serde(skip)]
+ pub id: String,
+ pub title: String,
+ pub is_open: bool,
+ pub is_merged: bool,
+ pub body: String,
+ pub last_update: DateTime,
+ pub url: String,
+ pub base_ref: String,
+}
+
+#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
+#[serde(deny_unknown_fields)]
+pub enum PullAction {
+ New,
+ Closed,
+ NewClosed,
+ Merged,
+ NewMerged,
+}