Common/StatusBar/
StatusBarProvider.rs

1// File: Common/Source/StatusBar/StatusBarProvider.rs
2// Role: Defines the abstract service trait for creating and managing status bar
3// items. Responsibilities:
4//   - Provide a contract for setting and disposing of persistent status bar
5//     items.
6//   - Provide a contract for showing and hiding temporary status bar messages.
7//   - Define the reverse call for resolving dynamic tooltips.
8
9//! # StatusBarProvider Trait
10//!
11//! Defines the abstract service trait for creating and managing status bar
12//! items and messages contributed by extensions.
13
14use async_trait::async_trait;
15use serde_json::Value;
16
17use super::DTO::StatusBarEntryDTO::StatusBarEntryDTO;
18use crate::{Environment::Environment::Environment, Error::CommonError::CommonError};
19
20/// An abstract service contract for an environment component that can manage
21/// the state and rendering of status bar entries and temporary messages.
22///
23/// This trait is implemented by `MountainEnvironment` and defines the
24/// operations that `Cocoon` can request from the host to manage the UI state of
25/// the status bar.
26#[async_trait]
27pub trait StatusBarProvider: Environment + Send + Sync {
28	/// Informs the host to create a new status bar entry or update an existing
29	/// one. The `EntryIdentifier` within the DTO is used to identify the
30	/// entry.
31	///
32	/// # Parameters
33	/// * `Entry`: The DTO containing the complete state of the status bar item.
34	async fn SetStatusBarEntry(&self, Entry:StatusBarEntryDTO) -> Result<(), CommonError>;
35
36	/// Informs the host to dispose of (remove) a status bar entry from the UI.
37	///
38	/// # Parameters
39	/// * `EntryIdentifier`: The unique identifier of the entry to remove.
40	async fn DisposeStatusBarEntry(&self, EntryIdentifier:String) -> Result<(), CommonError>;
41
42	/// Shows a temporary message in the status bar. The message is identified
43	/// by a unique ID so it can be disposed of later.
44	///
45	/// # Parameters
46	/// * `MessageIdentifier`: A unique ID for this message instance.
47	/// * `Text`: The text content of the message.
48	async fn SetStatusBarMessage(&self, MessageIdentifier:String, Text:String) -> Result<(), CommonError>;
49
50	/// Disposes of a temporary status bar message.
51	///
52	/// # Parameters
53	/// * `MessageIdentifier`: The unique ID of the message to remove.
54	async fn DisposeStatusBarMessage(&self, MessageIdentifier:String) -> Result<(), CommonError>;
55
56	/// This method is called *by* the host *to* the extension host (`Cocoon`)
57	/// when a dynamic tooltip needs to be resolved for a status bar item.
58	///
59	/// # Parameters
60	/// * `EntryIdentifier`: The unique identifier of the entry for which to
61	///   provide a tooltip.
62	///
63	/// # Returns
64	/// A `Result` containing an optional DTO for the tooltip (e.g.,
65
66	/// `IMarkdownStringDTO`).
67	async fn ProvideTooltip(&self, EntryIdentifier:String) -> Result<Option<Value>, CommonError>;
68}