From f411daceacad66e0bd774fda7d3c5ef8533cc55c Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 26 May 2026 20:04:02 +0900 Subject: refactor(io): share IOInterface via Rc> handle Co-Authored-By: Claude Opus 4.7 --- crates/shirabe/src/downloader/vcs_downloader.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'crates/shirabe/src/downloader/vcs_downloader.rs') diff --git a/crates/shirabe/src/downloader/vcs_downloader.rs b/crates/shirabe/src/downloader/vcs_downloader.rs index 096e93d..736d433 100644 --- a/crates/shirabe/src/downloader/vcs_downloader.rs +++ b/crates/shirabe/src/downloader/vcs_downloader.rs @@ -17,6 +17,7 @@ use crate::downloader::ChangeReportInterface; use crate::downloader::DownloaderInterface; use crate::downloader::VcsCapableDownloaderInterface; use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::package::PackageInterface; use crate::package::dumper::ArrayDumper; use crate::package::version::VersionGuesser; @@ -26,7 +27,7 @@ use crate::util::ProcessExecutor; #[derive(Debug)] pub struct VcsDownloaderBase { - pub io: Box, + pub io: std::rc::Rc>, pub config: std::rc::Rc>, pub process: std::rc::Rc>, pub filesystem: std::rc::Rc>, @@ -35,13 +36,14 @@ pub struct VcsDownloaderBase { impl VcsDownloaderBase { pub fn new( - io: Box, + io: std::rc::Rc>, config: std::rc::Rc>, process: Option>>, fs: Option>>, ) -> Self { - let process = process - .unwrap_or_else(|| std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(())))); + let process = process.unwrap_or_else(|| { + std::rc::Rc::new(std::cell::RefCell::new(ProcessExecutor::new(None))) + }); let filesystem = fs.unwrap_or_else(|| std::rc::Rc::new(std::cell::RefCell::new(Filesystem::new(None)))); Self { @@ -72,7 +74,7 @@ impl VcsDownloaderBase { pub trait VcsDownloader: DownloaderInterface + ChangeReportInterface + VcsCapableDownloaderInterface { - fn io(&self) -> &dyn IOInterface; + fn io(&self) -> std::rc::Rc>; fn io_mut(&mut self) -> &mut dyn IOInterface; fn config(&self) -> &std::rc::Rc>; fn config_mut(&mut self) -> &mut std::rc::Rc>; @@ -442,7 +444,7 @@ pub trait VcsDownloader: self.config().clone(), self.process().clone(), parser.clone(), - Some(self.io().clone_box()), + Some(self.io().clone()), ); let dumper = ArrayDumper::new(); -- cgit v1.3.1