Common/Output/
RegisterOutputChannel.rs

1//! # RegisterOutputChannel Effect
2//!
3//! Defines the `ActionEffect` for registering a new output channel.
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 register a new output channel
11/// with the host application.
12///
13/// It uses the `OutputChannelManager` capability from the environment.
14///
15/// # Parameters
16/// * `Name`: The human-readable name of the channel.
17/// * `LanguageIdentifier`: An optional language ID for syntax highlighting.
18///
19/// # Returns
20/// An `ActionEffect` that resolves with a unique `String` identifier for the
21/// newly created channel.
22pub fn RegisterOutputChannel(
23	Name:String,
24
25	LanguageIdentifier:Option<String>,
26) -> ActionEffect<Arc<dyn OutputChannelManager>, CommonError, String> {
27	ActionEffect::New(Arc::new(move |Manager:Arc<dyn OutputChannelManager>| {
28		let NameClone = Name.clone();
29
30		let LanguageIdentifierClone = LanguageIdentifier.clone();
31
32		Box::pin(async move { Manager.RegisterChannel(NameClone, LanguageIdentifierClone).await })
33	}))
34}