Common/Output/
RevealOutputChannel.rs

1//! # RevealOutputChannel Effect
2//!
3//! Defines the `ActionEffect` for revealing an output channel in the UI.
4
5use std::sync::Arc;
6
7use super::OutputChannelManager::OutputChannelManager;
8use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError};
9
10/// Creates an effect that, when executed, will reveal (open and focus) the
11/// specified output channel in the user interface.
12///
13/// It uses the `OutputChannelManager` capability from the environment.
14///
15/// # Parameters
16/// * `ChannelIdentifier`: The unique ID of the target channel.
17/// * `PreserveFocus`: If `true`, the focus will remain in its current location
18///   instead of moving to the output channel panel.
19///
20/// # Returns
21/// An `ActionEffect` that resolves to `()` on success.
22pub fn RevealOutputChannel(
23	ChannelIdentifier:String,
24
25	PreserveFocus:bool,
26) -> ActionEffect<Arc<dyn OutputChannelManager>, CommonError, ()> {
27	ActionEffect::New(Arc::new(move |Manager:Arc<dyn OutputChannelManager>| {
28		let IdentifierClone = ChannelIdentifier.clone();
29
30		Box::pin(async move { Manager.Reveal(IdentifierClone, PreserveFocus).await })
31	}))
32}