Mountain/Environment/OutputProvider/
mod.rs

1//! # OutputProvider (Environment)
2//!
3//! Implements the
4//! [`OutputChannelManager`](CommonLibrary::Output::OutputChannelManager) trait
5//! for
6//! [`MountainEnvironment`](crate::Environment::MountainEnvironment::MountainEnvironment).
7//!
8//! This provider manages multiple output channels (e.g., 'Extension Host',
9//! 'JavaScript', 'Git'), handling channel lifecycle, content management, and UI
10//! visibility. It maintains in-memory buffers with size limits and emits Tauri
11//! events to the Sky frontend for UI updates.
12//!
13//! ## Implementation Strategy
14//!
15//! The trait implementation is split across multiple helper modules for
16//! maintainability:
17//! - `ChannelLifecycle`: `RegisterChannel`, `Dispose`
18//! - `ChannelContent`: `Append`, `Replace`, `Clear`
19//! - `ChannelVisibility`: `Reveal`, `Close`
20//!
21//! The single `impl OutputChannelManager for MountainEnvironment` block in this
22//! file delegates to those helper functions. This satisfies Rust's orphan rules
23//! while keeping code organized.
24
25use CommonLibrary::Output::OutputChannelManager::OutputChannelManager;
26use async_trait::async_trait;
27
28// Private helper modules (not re-exported)
29mod ChannelLifecycle;
30mod ChannelContent;
31mod ChannelVisibility;
32
33#[async_trait]
34impl OutputChannelManager for crate::Environment::MountainEnvironment::MountainEnvironment {
35	async fn RegisterChannel(
36		&self,
37		name:String,
38		language_identifier:Option<String>,
39	) -> Result<String, CommonLibrary::Error::CommonError::CommonError> {
40		ChannelLifecycle::register_channel(self, name, language_identifier).await
41	}
42
43	async fn Append(
44		&self,
45		channel_identifier:String,
46		value:String,
47	) -> Result<(), CommonLibrary::Error::CommonError::CommonError> {
48		ChannelContent::append_to_channel(self, channel_identifier, value).await
49	}
50
51	async fn Replace(
52		&self,
53		channel_identifier:String,
54		value:String,
55	) -> Result<(), CommonLibrary::Error::CommonError::CommonError> {
56		ChannelContent::replace_channel_content(self, channel_identifier, value).await
57	}
58
59	async fn Clear(&self, channel_identifier:String) -> Result<(), CommonLibrary::Error::CommonError::CommonError> {
60		ChannelContent::clear_channel(self, channel_identifier).await
61	}
62
63	async fn Reveal(
64		&self,
65		channel_identifier:String,
66		preserve_focus:bool,
67	) -> Result<(), CommonLibrary::Error::CommonError::CommonError> {
68		ChannelVisibility::reveal_channel(self, channel_identifier, preserve_focus).await
69	}
70
71	async fn Close(&self, channel_identifier:String) -> Result<(), CommonLibrary::Error::CommonError::CommonError> {
72		ChannelVisibility::close_channel(self, channel_identifier).await
73	}
74
75	async fn Dispose(&self, channel_identifier:String) -> Result<(), CommonLibrary::Error::CommonError::CommonError> {
76		ChannelLifecycle::dispose_channel(self, channel_identifier).await
77	}
78}