From 82c9923cc6413cf3122cb0fe9443ab30516d5209 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Thu, 18 Jul 2024 12:03:32 +0300 Subject: [PATCH] Implement State struct and enum with stringification --- src/main.rs | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index d1d4cac..3fb02f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,19 +1,31 @@ +use crate::State::{Active, Closed, Done, Open}; +use nostr_sdk::async_utility::futures_util::TryFutureExt; +use nostr_sdk::prelude::*; +use once_cell::sync::Lazy; use std::borrow::Borrow; use std::collections::HashMap; use std::env::args; +use std::fmt; use std::io::{stdin, stdout, Write}; use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4}; -use std::ops::{Deref}; +use std::ops::Deref; use std::time::Duration; -use once_cell::sync::Lazy; -use nostr_sdk::async_utility::futures_util::TryFutureExt; -use nostr_sdk::prelude::*; +/* + 1: Task Description + Issue Tracking: https://github.com/nostr-protocol/nips/blob/master/34.md + 1621: MD Issue + 1622: MD Reply + 1630-1633: Status (Time-tracking, Kanban) + Calendar: https://github.com/nostr-protocol/nips/blob/master/52.md + 31922 (GANTT, only Date) + 31923 (Calendar, with Time) +*/ -static TASK_KIND: Lazy = Lazy::new(||Kind::from(90002)); +static TASK_KIND: Lazy = Lazy::new(|| Kind::from(1621)); -static MY_KEYS: Lazy = Lazy::new(||Keys::generate()); -static CLIENT: Lazy = Lazy::new(||Client::new(MY_KEYS.borrow().deref())); +static MY_KEYS: Lazy = Lazy::new(|| Keys::generate()); +static CLIENT: Lazy = Lazy::new(|| Client::new(MY_KEYS.borrow().deref())); #[tokio::main] async fn main() { @@ -152,4 +164,22 @@ impl Task { children: Vec::new(), } } -} \ No newline at end of file +} + +struct TaskState { + name: String, + state: State, + time: Timestamp, +} +#[derive(Debug)] +enum State { + Open, + Active, + Done, + Closed, +} +impl fmt::Display for State { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Debug::fmt(self, f) + } +}