aboutsummaryrefslogtreecommitdiff
path: root/karlcommon
diff options
context:
space:
mode:
authormetamuffin <yvchraiqi@protonmail.com>2022-06-10 10:59:47 +0200
committermetamuffin <yvchraiqi@protonmail.com>2022-06-10 10:59:47 +0200
commit6f6db73a126057514912c5e6b372ef225a1065b7 (patch)
tree22518de3c0213d85166aa53f0fa476a6d8e2d780 /karlcommon
parent3238f8517097745032e19b3e26f57f0465a00b28 (diff)
downloadkarlender-6f6db73a126057514912c5e6b372ef225a1065b7.tar
karlender-6f6db73a126057514912c5e6b372ef225a1065b7.tar.bz2
karlender-6f6db73a126057514912c5e6b372ef225a1065b7.tar.zst
moved code to another crate
Diffstat (limited to 'karlcommon')
-rw-r--r--karlcommon/Cargo.toml7
-rw-r--r--karlcommon/src/lib.rs70
2 files changed, 77 insertions, 0 deletions
diff --git a/karlcommon/Cargo.toml b/karlcommon/Cargo.toml
new file mode 100644
index 0000000..6ce571e
--- /dev/null
+++ b/karlcommon/Cargo.toml
@@ -0,0 +1,7 @@
+[package]
+name = "karlcommon"
+version = "0.1.0"
+edition = "2021"
+
+[dependencies]
+serde = { version = "1.0.137", features = ["derive"] }
diff --git a/karlcommon/src/lib.rs b/karlcommon/src/lib.rs
new file mode 100644
index 0000000..809a036
--- /dev/null
+++ b/karlcommon/src/lib.rs
@@ -0,0 +1,70 @@
+use serde::{Deserialize, Serialize};
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(tag = "type", content = "data", rename_all = "snake_case")]
+pub enum ClientboundPacket {
+ Handshake { version: String },
+ Error(String),
+ DownloadResponse(Vec<Task>),
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(tag = "type", content = "data", rename_all = "snake_case")]
+pub enum ServerboundPacket {
+ Download,
+ UpdateTask(Task),
+ RemoveTask(u64),
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct Task {
+ pub id: u64,
+ pub name: String,
+ pub description: String,
+
+ pub tags: Vec<String>,
+ pub priority: f64,
+
+ pub completed: Option<u64>,
+ pub scheduled: Option<u64>,
+
+ pub occurence: Option<Condition>,
+ pub deadline: Option<Condition>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum Condition {
+ From(Box<Condition>),
+
+ Or(Vec<Condition>),
+ And(Vec<Condition>),
+ Invert(Box<Condition>),
+
+ Equal {
+ prop: Property,
+ value: i64,
+ modulus: Option<i64>,
+ },
+ Range {
+ prop: Property,
+ min: i64,
+ max: i64,
+ modulus: Option<i64>,
+ },
+}
+
+#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum Property {
+ Year,
+ Monthofyear,
+ Weekofmonth,
+ Dayofyear,
+ Dayofmonth,
+ Dayofweek,
+ Hour,
+ Minute,
+ Second,
+ Unix,
+}