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
32	AppState:&std::sync::Arc<ApplicationState>,
33) -> Result<(), String> {
34	match crate::ApplicationState::Internal::ExtensionScanner::ScanAndPopulateExtensions::ScanAndPopulateExtensions(
35		ApplicationHandle.clone(),
36		&AppState.Extension,
37	)
38	.await
39	{
40		Ok(()) => {
41			dev_log!(
42				"extensions",
43				"[Extensions] [Populate] Extensions scanned and populated successfully."
44			);
45
46			Ok(())
47		},
48
49		Err(e) => {
50			dev_log!("extensions", "error: [Extensions] [Populate] Failed: {}", e);
51
52			Err(format!("Failed to scan and populate extensions: {}", e))
53		},
54	}
55}