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