Skip to main content

Mountain/Binary/Extension/
ExtensionPopulate.rs

1//! # Extension Populate Module
2//!
3//! Scans and populates extensions from configured scan paths.
4
5use crate::{
6    ApplicationState::ApplicationState,
7    dev_log,
8};
9
10/// Scans and populates extensions from the configured scan paths.
11///
12/// # Arguments
13///
14/// * `ApplicationHandle` - The Tauri application handle
15/// * `AppState` - The application state containing extension information
16///
17/// # Returns
18///
19/// A `Result` indicating success or failure.
20///
21/// # Extension Scanning Process
22///
23/// This function performs:
24/// - Scanning all configured extension directories
25/// - Parsing extension metadata and manifests
26/// - Loading extension capabilities
27/// - Registering extensions with the application
28///
29/// # Errors
30///
31/// Returns an error if extension scanning or population fails.
32pub async fn ExtensionPopulate(
33	ApplicationHandle:tauri::AppHandle,
34	AppState:&std::sync::Arc<ApplicationState>,
35) -> Result<(), String> {
36	match crate::ApplicationState::Internal::ExtensionScanner::ScanAndPopulateExtensions::ScanAndPopulateExtensions(ApplicationHandle.clone(), &AppState.Extension).await {
37		Ok(()) => {
38			dev_log!(
39				"extensions",
40				"[Extensions] [Populate] Extensions scanned and populated successfully."
41			);
42			Ok(())
43		},
44		Err(e) => {
45			dev_log!("extensions", "error: [Extensions] [Populate] Failed: {}", e);
46			Err(format!("Failed to scan and populate extensions: {}", e))
47		},
48	}
49}