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