Mountain/Environment/
StatusBarProvider.rs

1//! # StatusBarProvider (Environment)
2//!
3//! Implements the `StatusBarProvider` trait for the `MountainEnvironment`. This
4//! provider handles creating, updating, and removing status bar items, and
5//! orchestrates communication between the `Cocoon` sidecar and the `Sky`
6//! frontend.
7
8use std::sync::Arc;
9
10use CommonLibrary::{
11	Environment::Requires::Requires,
12	Error::CommonError::CommonError,
13	IPC::{DTO::ProxyTarget::ProxyTarget, IPCProvider::IPCProvider},
14	StatusBar::{DTO::StatusBarEntryDTO::StatusBarEntryDTO, StatusBarProvider::StatusBarProvider},
15};
16use async_trait::async_trait;
17use log::info;
18use serde_json::{Value, json};
19use tauri::Emitter;
20
21use super::{MountainEnvironment::MountainEnvironment, Utility};
22
23// Private submodules containing the actual implementation
24#[path = "StatusBarProvider/entry_management.rs"]
25mod entry_management;
26#[path = "StatusBarProvider/message_management.rs"]
27mod message_management;
28#[path = "StatusBarProvider/tooltip.rs"]
29mod tooltip;
30
31#[async_trait]
32impl StatusBarProvider for MountainEnvironment {
33	/// Creates a new status bar entry or updates an existing one.
34	async fn SetStatusBarEntry(&self, entry:StatusBarEntryDTO) -> Result<(), CommonError> {
35		entry_management::set_status_bar_entry_impl(self, entry).await
36	}
37
38	/// Removes a status bar item from the UI.
39	async fn DisposeStatusBarEntry(&self, entry_identifier:String) -> Result<(), CommonError> {
40		entry_management::dispose_status_bar_entry_impl(self, entry_identifier).await
41	}
42
43	/// Shows a temporary message in the status bar.
44	async fn SetStatusBarMessage(&self, message_identifier:String, text:String) -> Result<(), CommonError> {
45		message_management::set_status_bar_message_impl(self, message_identifier, text).await
46	}
47
48	/// Disposes of a temporary status bar message.
49	async fn DisposeStatusBarMessage(&self, message_identifier:String) -> Result<(), CommonError> {
50		message_management::dispose_status_bar_message_impl(self, message_identifier).await
51	}
52
53	/// Resolves a dynamic tooltip by making a reverse call to the extension
54	/// host.
55	async fn ProvideTooltip(&self, entry_identifier:String) -> Result<Option<Value>, CommonError> {
56		tooltip::provide_tooltip_impl(self, entry_identifier).await
57	}
58}