From e29295246f3aa7a3b2271874c6bdb7b3400364d0 Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Thu, 14 Aug 2025 17:11:01 -0700 Subject: [PATCH] broken modules --- Cargo.lock | 2 +- Cargo.toml | 4 +++- VERSION | 1 + VERSIONING.md | 32 ++++++++++++++++++++++++++++++++ src/app/mod.rs | 3 ++- src/config.rs | 6 +++--- src/error.rs | 4 ++-- src/{lib.rs => jocalsend.rs} | 16 ++++++---------- src/main.rs | 11 ++++++++++- src/models.rs | 4 ++-- src/transfer.rs | 16 ++++++++-------- 11 files changed, 70 insertions(+), 29 deletions(-) create mode 100644 VERSION create mode 100644 VERSIONING.md rename src/{lib.rs => jocalsend.rs} (97%) diff --git a/Cargo.lock b/Cargo.lock index 3686068..31c4896 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1324,7 +1324,7 @@ dependencies = [ [[package]] name = "jocalsend" -version = "1.0.0" +version = "1.6.1" dependencies = [ "axum", "axum-server", diff --git a/Cargo.toml b/Cargo.toml index b63452a..9bee608 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,8 @@ [package] name = "jocalsend" -version = "1.0.0" +# 1.61803398874989484 +#----^ +version = "1.6.1" edition = "2024" authors = ["Joe Ardent "] keywords = ["p2p", "localsend", "tui", "linux"] diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..4213d88 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.61 diff --git a/VERSIONING.md b/VERSIONING.md new file mode 100644 index 0000000..5dfd982 --- /dev/null +++ b/VERSIONING.md @@ -0,0 +1,32 @@ +# Golden Versioning + +This software is versioned under a scheme I call "goldver", as an homage to the +vastly inferior [semver](https://semver.org). + +## What does "goldver" mean? + +When projects are versioned with goldver, the first version is "1". Note that it +is not "1.0", or, "1.0-prealpha-release-preview", or anything nonsensical like +that. As new versions are released, decimals from *phi*, the [Golden +Ratio](https://en.wikipedia.org/wiki/Golden_ratio), are appended after an +initial decimal point. So the second released version will be "1.6", the third +would be "1.61", etc., and on until perfection is asymptotically approached as +the number of released versions goes to infinity. + +## Wait, didn't Donald Knuth do this? + +No! He uses [pi for TeX and e for MetaFont](https://texfaq.org/FAQ-TeXfuture), +obviously COMPLETELY different. + +## Ok. + +Cool. + +## What version is Julid now? + +Canonically, see the `VERSION` file. Heretically, once there have been +at least three releases, the version string in the `Cargo.toml` file will +always be of the form "1.6.x", where *x* is at least one digit long, starting +with "1". Each subsequent release will append the next digit of *phi* to +*x*. The number of releases can be calculated by counting the number of digits +in *x* and adding 2 to that. diff --git a/src/app/mod.rs b/src/app/mod.rs index 4ba9afb..ab9a973 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -6,7 +6,6 @@ use std::{ use crossterm::event::{Event, EventStream, KeyCode, KeyEvent, KeyEventKind}; use futures::{FutureExt, StreamExt}; -use jocalsend::{JocalEvent, JocalService, ReceiveDialog, ReceiveRequest, error::Result}; use julid::Julid; use log::{LevelFilter, debug, error, warn}; use ratatui::{ @@ -18,6 +17,8 @@ use simsearch::{SearchOptions, SimSearch}; use tokio::sync::mpsc::UnboundedReceiver; use tui_input::{Input, backend::crossterm::EventHandler}; +use crate::jocalsend::{JocalEvent, JocalService, ReceiveDialog, ReceiveRequest, error::Result}; + pub mod widgets; #[derive(Debug, Clone, PartialEq, Eq)] diff --git a/src/config.rs b/src/config.rs index 792cea3..1567d62 100644 --- a/src/config.rs +++ b/src/config.rs @@ -12,8 +12,8 @@ use local_ip_address::local_ip; use serde::{Deserialize, Deserializer, Serialize}; use crate::{ - DEFAULT_PORT, MULTICAST_IP, - error::{LocalSendError, Result}, + error::{JocalError, Result}, + jocalsend::{DEFAULT_PORT, MULTICAST_IP}, models::Device, }; @@ -41,7 +41,7 @@ impl Default for Config { impl Config { pub fn new() -> Result { - let dirs = directories::BaseDirs::new().ok_or(LocalSendError::NoHomeDir)?; + let dirs = directories::BaseDirs::new().ok_or(JocalError::NoHomeDir)?; let download_dir = dirs.home_dir().join("jocalsend-downloads"); let config_file = dirs.config_dir().join("jocalsend.toml"); diff --git a/src/error.rs b/src/error.rs index a0adfdf..ad49ea8 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,5 +1,5 @@ #[derive(Debug, thiserror::Error)] -pub enum LocalSendError { +pub enum JocalError { #[error("IO error: {0}")] IOError(#[from] std::io::Error), @@ -64,4 +64,4 @@ pub enum LocalSendError { ConfigParseError(#[from] Box), } -pub type Result = std::result::Result; +pub type Result = std::result::Result; diff --git a/src/lib.rs b/src/jocalsend.rs similarity index 97% rename from src/lib.rs rename to src/jocalsend.rs index 1d5559a..1a1eba3 100644 --- a/src/lib.rs +++ b/src/jocalsend.rs @@ -1,10 +1,3 @@ -pub mod config; -pub mod discovery; -pub mod error; -pub mod http_server; -pub mod models; -pub mod transfer; - use std::{ collections::BTreeMap, fmt::Debug, @@ -14,10 +7,8 @@ use std::{ time::Duration, }; -pub use config::Config; use julid::Julid; use log::error; -use models::{Device, FileMetadata}; use tokio::{ net::UdpSocket, sync::{ @@ -26,7 +17,12 @@ use tokio::{ }, task::JoinSet, }; -use transfer::Session; + +use crate::{ + config::Config, + models::{Device, FileMetadata}, + transfer::Session, +}; pub const DEFAULT_PORT: u16 = 53317; pub const MULTICAST_IP: Ipv4Addr = Ipv4Addr::new(224, 0, 0, 167); diff --git a/src/main.rs b/src/main.rs index a1c3f56..3932011 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,6 @@ use std::{path::Path, str::FromStr, time::Duration}; use clap::Parser; -use jocalsend::{Config, DEFAULT_INTERVAL, JocalService, JocalTasks, error::Result}; use log::{error, info}; use ratatui::DefaultTerminal; use ratatui_explorer::FileExplorer; @@ -14,6 +13,16 @@ use app::{App, CurrentScreen, Peer}; mod cli; use cli::Cli; +mod jocalsend; +use jocalsend::{Config, DEFAULT_INTERVAL, JocalService, JocalTasks, error::Result}; + +mod config; +mod discovery; +mod error; +mod http_server; +mod models; +mod transfer; + fn main() -> Result<()> { // just in case we need to display the help let _ = Cli::parse(); diff --git a/src/models.rs b/src/models.rs index 5106cf4..6cda681 100644 --- a/src/models.rs +++ b/src/models.rs @@ -4,7 +4,7 @@ use chrono::{DateTime, Utc}; use julid::Julid; use serde::{Deserialize, Serialize}; -use crate::error::LocalSendError; +use crate::error::JocalError; #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -33,7 +33,7 @@ impl FileMetadata { pub fn from_path(path: &Path) -> crate::error::Result { let metadata = path.metadata()?; if !metadata.is_file() { - return Err(LocalSendError::NotAFile); + return Err(JocalError::NotAFile); } let id = path.to_str().unwrap().to_string(); diff --git a/src/transfer.rs b/src/transfer.rs index 0cd62a1..af1d21e 100644 --- a/src/transfer.rs +++ b/src/transfer.rs @@ -15,7 +15,7 @@ use tokio::sync::mpsc::{UnboundedSender, unbounded_channel}; use crate::{ JocalEvent, JocalService, Peers, ReceiveDialog, ReceiveRequest, SendingType, Sessions, - error::{LocalSendError, Result}, + error::{JocalError, Result}, models::{Device, FileMetadata}, }; @@ -68,7 +68,7 @@ impl JocalService { let sessions = self.sessions.lock().await; let session = sessions .get(session_id) - .ok_or(LocalSendError::SessionNotFound)?; + .ok_or(JocalError::SessionNotFound)?; let request = self .client @@ -80,7 +80,7 @@ impl JocalService { .await?; if request.status() != 200 { - return Err(LocalSendError::CancelFailed); + return Err(JocalError::CancelFailed); } Ok(()) @@ -361,11 +361,11 @@ async fn do_send_bytes( let session = sessions.get(session_id).unwrap(); if session.status != SessionStatus::Active { - return Err(LocalSendError::SessionInactive); + return Err(JocalError::SessionInactive); } if session.file_tokens.get(content_id) != Some(token) { - return Err(LocalSendError::InvalidToken); + return Err(JocalError::InvalidToken); } let request = client @@ -379,7 +379,7 @@ async fn do_send_bytes( if response.status() != 200 { log::trace!("non-200 remote response: {response:?}"); - return Err(LocalSendError::UploadFailed); + return Err(JocalError::UploadFailed); } Ok(()) @@ -395,7 +395,7 @@ async fn do_prepare_upload( files: BTreeMap, ) -> Result { let Some((addr, device)) = peers.lock().await.get(peer).cloned() else { - return Err(LocalSendError::PeerNotFound); + return Err(JocalError::PeerNotFound); }; log::debug!("preparing upload request"); @@ -421,7 +421,7 @@ async fn do_prepare_upload( let response: PrepareUploadResponse = match response.json().await { Err(e) => { error!("got error deserializing response: {e:?}"); - return Err(LocalSendError::RequestError(e)); + return Err(JocalError::RequestError(e)); } Ok(r) => r, };