From 76db19f14c616e879f613b533ee5072c661f8a10 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 10 Jun 2022 11:18:21 +0200 Subject: stuff --- karlcommon/src/lib.rs | 82 +++++++++------------------------------------------ 1 file changed, 14 insertions(+), 68 deletions(-) (limited to 'karlcommon/src/lib.rs') diff --git a/karlcommon/src/lib.rs b/karlcommon/src/lib.rs index 809a036..8e7694b 100644 --- a/karlcommon/src/lib.rs +++ b/karlcommon/src/lib.rs @@ -1,70 +1,16 @@ -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), -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(tag = "type", content = "data", rename_all = "snake_case")] -pub enum ServerboundPacket { - Download, - UpdateTask(Task), - RemoveTask(u64), +pub mod protocol; +use std::{ + os::unix::prelude::MetadataExt, + path::{Path, PathBuf}, +}; + +pub use protocol::*; + +pub fn socket_path() -> PathBuf { + Path::new("/run/user") + .join(format!("{}", getuid())) + .join("calendar") } - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct Task { - pub id: u64, - pub name: String, - pub description: String, - - pub tags: Vec, - pub priority: f64, - - pub completed: Option, - pub scheduled: Option, - - pub occurence: Option, - pub deadline: Option, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum Condition { - From(Box), - - Or(Vec), - And(Vec), - Invert(Box), - - Equal { - prop: Property, - value: i64, - modulus: Option, - }, - Range { - prop: Property, - min: i64, - max: i64, - modulus: Option, - }, -} - -#[derive(Debug, Clone, Copy, Serialize, Deserialize)] -#[serde(rename_all = "snake_case")] -pub enum Property { - Year, - Monthofyear, - Weekofmonth, - Dayofyear, - Dayofmonth, - Dayofweek, - Hour, - Minute, - Second, - Unix, +fn getuid() -> u32 { + std::fs::metadata("/proc/self").unwrap().uid() } -- cgit v1.2.3-70-g09d2