From 949c6459aa7683453a7160423b689ceadb08954b Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Wed, 4 Sep 2024 08:04:48 +0100 Subject: refactor: organise into lib and bin structure the make the code more readable this commit just moves the files, the next commit should fix the imports --- src/config.rs | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 src/config.rs (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs deleted file mode 100644 index 547fe7e..0000000 --- a/src/config.rs +++ /dev/null @@ -1,47 +0,0 @@ -use anyhow::{anyhow, Result}; -use directories::ProjectDirs; -use nostr::PublicKey; -use nostr_sdk::Timestamp; -use serde::{self, Deserialize, Serialize}; - -pub fn get_dirs() -> Result { - ProjectDirs::from("", "", "ngit").ok_or(anyhow!( - "should find operating system home directories with rust-directories crate" - )) -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct UserRef { - pub public_key: PublicKey, - pub metadata: UserMetadata, - pub relays: UserRelays, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct UserMetadata { - pub name: String, - pub created_at: Timestamp, -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct UserRelays { - pub relays: Vec, - pub created_at: Timestamp, -} - -impl UserRelays { - pub fn write(&self) -> Vec { - self.relays - .iter() - .filter(|r| r.write) - .map(|r| r.url.clone()) - .collect() - } -} - -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] -pub struct UserRelayRef { - pub url: String, - pub read: bool, - pub write: bool, -} -- cgit v1.2.3