From 944be0cd5a5818e3c44bf3981c9c4c98b0fe2d4c Mon Sep 17 00:00:00 2001 From: Aleksei Voronov Date: Sat, 16 Sep 2023 17:21:18 +0200 Subject: [PATCH] Convert into more modern Rust module structure And also use re-exports liberally for shorter imports --- src/main.rs | 12 ++++++------ src/processes.rs | 7 +++++++ src/processes/feed_server/server.rs | 2 +- src/processes/feed_server/state.rs | 2 +- src/processes/mod.rs | 3 --- src/processes/post_indexer.rs | 2 +- src/processes/profile_classifier.rs | 6 +++--- src/services.rs | 7 +++++++ src/services/{bluesky/mod.rs => bluesky.rs} | 0 src/services/mod.rs | 3 --- 10 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 src/processes.rs delete mode 100644 src/processes/mod.rs create mode 100644 src/services.rs rename src/services/{bluesky/mod.rs => bluesky.rs} (100%) delete mode 100644 src/services/mod.rs diff --git a/src/main.rs b/src/main.rs index e4ad79c..1248154 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,12 +5,12 @@ mod services; use anyhow::Result; use crate::config::Config; -use crate::processes::feed_server::FeedServer; -use crate::processes::post_indexer::PostIndexer; -use crate::processes::profile_classifier::ProfileClassifier; -use crate::services::ai::AI; -use crate::services::bluesky::Bluesky; -use crate::services::database::Database; +use crate::processes::FeedServer; +use crate::processes::PostIndexer; +use crate::processes::ProfileClassifier; +use crate::services::AI; +use crate::services::Bluesky; +use crate::services::Database; #[tokio::main] async fn main() -> Result<()> { diff --git a/src/processes.rs b/src/processes.rs new file mode 100644 index 0000000..a0c8736 --- /dev/null +++ b/src/processes.rs @@ -0,0 +1,7 @@ +mod feed_server; +mod post_indexer; +mod profile_classifier; + +pub use feed_server::FeedServer; +pub use post_indexer::PostIndexer; +pub use profile_classifier::ProfileClassifier; diff --git a/src/processes/feed_server/server.rs b/src/processes/feed_server/server.rs index ca0f85d..aa58f44 100644 --- a/src/processes/feed_server/server.rs +++ b/src/processes/feed_server/server.rs @@ -5,7 +5,7 @@ use axum::routing::get; use axum::{Router, Server}; use crate::config::Config; -use crate::services::database::Database; +use crate::services::Database; use super::endpoints::{describe_feed_generator, did_json, get_feed_skeleton, root}; use super::state::FeedServerState; diff --git a/src/processes/feed_server/state.rs b/src/processes/feed_server/state.rs index 0100262..5188854 100644 --- a/src/processes/feed_server/state.rs +++ b/src/processes/feed_server/state.rs @@ -1,5 +1,5 @@ use crate::config::Config; -use crate::services::database::Database; +use crate::services::Database; #[derive(Clone)] pub struct FeedServerState { diff --git a/src/processes/mod.rs b/src/processes/mod.rs deleted file mode 100644 index 2820e1b..0000000 --- a/src/processes/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod feed_server; -pub mod post_indexer; -pub mod profile_classifier; diff --git a/src/processes/post_indexer.rs b/src/processes/post_indexer.rs index 9a5254f..aa118fd 100644 --- a/src/processes/post_indexer.rs +++ b/src/processes/post_indexer.rs @@ -2,7 +2,7 @@ use anyhow::Result; use async_trait::async_trait; use crate::services::bluesky::{Bluesky, Operation, OperationProcessor}; -use crate::services::database::Database; +use crate::services::Database; pub struct PostIndexer<'a> { database: &'a Database, diff --git a/src/processes/profile_classifier.rs b/src/processes/profile_classifier.rs index 9c4d5bb..fcc1f83 100644 --- a/src/processes/profile_classifier.rs +++ b/src/processes/profile_classifier.rs @@ -2,9 +2,9 @@ use std::time::Duration; use anyhow::Result; -use crate::services::ai::AI; -use crate::services::bluesky::Bluesky; -use crate::services::database::Database; +use crate::services::AI; +use crate::services::Bluesky; +use crate::services::Database; pub struct ProfileClassifier<'a> { database: &'a Database, diff --git a/src/services.rs b/src/services.rs new file mode 100644 index 0000000..6ad9a56 --- /dev/null +++ b/src/services.rs @@ -0,0 +1,7 @@ +mod ai; +pub mod bluesky; +mod database; + +pub use ai::AI; +pub use bluesky::Bluesky; +pub use database::Database; diff --git a/src/services/bluesky/mod.rs b/src/services/bluesky.rs similarity index 100% rename from src/services/bluesky/mod.rs rename to src/services/bluesky.rs diff --git a/src/services/mod.rs b/src/services/mod.rs deleted file mode 100644 index 468ea61..0000000 --- a/src/services/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub mod ai; -pub mod bluesky; -pub mod database;