Skip to main content

Mountain/Environment/OutputProvider/
mod.rs

1//! # OutputProvider (Environment)
2//!
3//! Implements the
4//! [`OutputChannelManager`](CommonLibrary::Output::OutputChannelManager) trait
5//! for
6//! `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;
30
31mod ChannelContent;
32
33mod ChannelVisibility;
34
35#[async_trait]
36impl OutputChannelManager for crate::Environment::MountainEnvironment::MountainEnvironment {
37	async fn RegisterChannel(
38		&self,
39
40		name:String,
41
42		language_identifier:Option<String>,
43	) -> Result<String, CommonLibrary::Error::CommonError::CommonError> {
44		ChannelLifecycle::register_channel(self, name, language_identifier).await
45	}
46
47	async fn Append(
48		&self,
49
50		channel_identifier:String,
51
52		value:String,
53	) -> Result<(), CommonLibrary::Error::CommonError::CommonError> {
54		ChannelContent::append_to_channel(self, channel_identifier, value).await
55	}
56
57	async fn Replace(
58		&self,
59
60		channel_identifier:String,
61
62		value:String,
63	) -> Result<(), CommonLibrary::Error::CommonError::CommonError> {
64		ChannelContent::replace_channel_content(self, channel_identifier, value).await
65	}
66
67	async fn Clear(&self, channel_identifier:String) -> Result<(), CommonLibrary::Error::CommonError::CommonError> {
68		ChannelContent::clear_channel(self, channel_identifier).await
69	}
70
71	async fn Reveal(
72		&self,
73
74		channel_identifier:String,
75
76		preserve_focus:bool,
77	) -> Result<(), CommonLibrary::Error::CommonError::CommonError> {
78		ChannelVisibility::reveal_channel(self, channel_identifier, preserve_focus).await
79	}
80
81	async fn Close(&self, channel_identifier:String) -> Result<(), CommonLibrary::Error::CommonError::CommonError> {
82		ChannelVisibility::close_channel(self, channel_identifier).await
83	}
84
85	async fn Dispose(&self, channel_identifier:String) -> Result<(), CommonLibrary::Error::CommonError::CommonError> {
86		ChannelLifecycle::dispose_channel(self, channel_identifier).await
87	}
88}