From eea4efe87e455742ec17881ee93d8095925e8516 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Thu, 28 May 2026 22:43:11 +0900 Subject: refactor(repository): introduce Rc> handles for repositories Co-Authored-By: Claude Opus 4.7 (1M context) --- crates/shirabe/src/repository/repository_factory.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'crates/shirabe/src/repository/repository_factory.rs') diff --git a/crates/shirabe/src/repository/repository_factory.rs b/crates/shirabe/src/repository/repository_factory.rs index 908704c..1159da1 100644 --- a/crates/shirabe/src/repository/repository_factory.rs +++ b/crates/shirabe/src/repository/repository_factory.rs @@ -12,7 +12,7 @@ use crate::factory::Factory; use crate::io::IOInterface; use crate::json::JsonFile; use crate::repository::FilesystemRepository; -use crate::repository::RepositoryInterface; +use crate::repository::RepositoryInterfaceHandle; use crate::repository::RepositoryManager; use crate::util::HttpDownloader; use crate::util::ProcessExecutor; @@ -102,7 +102,7 @@ impl RepositoryFactory { repository: &str, allow_filesystem: bool, rm: Option<&mut RepositoryManager>, - ) -> anyhow::Result> { + ) -> anyhow::Result { let repo_config = Self::config_from_string(io.clone(), config, repository, allow_filesystem)?; Self::create_repo(io, config, repo_config, rm) @@ -113,7 +113,7 @@ impl RepositoryFactory { config: &std::rc::Rc>, repo_config: IndexMap, rm: Option<&mut RepositoryManager>, - ) -> anyhow::Result> { + ) -> anyhow::Result { let mut owned_rm; let rm = if let Some(rm) = rm { rm @@ -145,7 +145,7 @@ impl RepositoryFactory { io: Option>>, config: Option>>, rm: Option<&mut RepositoryManager>, - ) -> anyhow::Result>> { + ) -> anyhow::Result> { let config = match config { Some(c) => c, None => std::rc::Rc::new(std::cell::RefCell::new(Factory::create_config(None, None)?)), @@ -233,7 +233,7 @@ impl RepositoryFactory { pub fn default_repos_with_default_manager( io: std::rc::Rc>, - ) -> anyhow::Result>> { + ) -> anyhow::Result> { let config = std::rc::Rc::new(std::cell::RefCell::new(Factory::create_config( Some(io.clone()), None, @@ -247,8 +247,8 @@ impl RepositoryFactory { fn create_repos( rm: &mut RepositoryManager, repo_configs: Vec, - ) -> anyhow::Result>> { - let mut repo_map: IndexMap> = IndexMap::new(); + ) -> anyhow::Result> { + let mut repo_map: IndexMap = IndexMap::new(); for (index, repo) in repo_configs.into_iter().enumerate() { match &repo { @@ -290,7 +290,7 @@ impl RepositoryFactory { .to_string(); // TODO(phase-b): FilesystemRepository does not yet implement // RepositoryInterface; once it does, construct it from JsonFile here. - let created: Box = + let created: RepositoryInterfaceHandle = todo!("FilesystemRepository as dyn RepositoryInterface"); repo_map.insert(name, created); } else { @@ -323,7 +323,7 @@ impl RepositoryFactory { pub fn generate_repository_name( index: &PhpMixed, repo: &IndexMap, - existing_repos: &IndexMap>, + existing_repos: &IndexMap, ) -> String { let mut name = match index { PhpMixed::Int(_) => { @@ -344,7 +344,7 @@ impl RepositoryFactory { fn generate_repository_name_indexed( index: usize, repo: &IndexMap, - existing_repos: &IndexMap>, + existing_repos: &IndexMap, ) -> String { let mut name = if let Some(url) = repo.get("url").and_then(|v| v.as_string()) { Preg::replace("{^https?://}i", "", url).unwrap_or_else(|_| url.to_string()) -- cgit v1.3.1