Skip to content

Open-source download manager & offline media toolbox for YouTube, music, social media, learning platforms & 1,800+ sites. Built with Tauri 2.0, Rust & Svelte.

feat: update PlatformRegistry to use Arc instead of Box for platform downloaders

Tonhodf62c3aaa1ed
diff --git a/src-tauri/src/core/registry.rs b/src-tauri/src/core/registry.rs
index 8e6dc59b..c1a26216 100644
--- a/src-tauri/src/core/registry.rs
+++ b/src-tauri/src/core/registry.rs
@@ -1,7 +1,9 @@
+use std::sync::Arc;
+
use crate::platforms::traits::PlatformDownloader;
pub struct PlatformRegistry {
- platforms: Vec<Box<dyn PlatformDownloader>>,
+ platforms: Vec<Arc<dyn PlatformDownloader>>,
}
impl PlatformRegistry {
@@ -11,15 +13,15 @@ impl PlatformRegistry {
}
}
- pub fn register(&mut self, platform: Box<dyn PlatformDownloader>) {
+ pub fn register(&mut self, platform: Arc<dyn PlatformDownloader>) {
self.platforms.push(platform);
}
- pub fn find_platform(&self, url: &str) -> Option<&dyn PlatformDownloader> {
+ pub fn find_platform(&self, url: &str) -> Option<Arc<dyn PlatformDownloader>> {
self.platforms
.iter()
.find(|p| p.can_handle(url))
- .map(|p| p.as_ref())
+ .cloned()
}
}