Common/Output/CloseOutputChannelView.rs
1//! # CloseOutputChannelView Effect
2//!
3//! Defines the `ActionEffect` for closing the view of an output channel in the
4//! UI.
5
6use std::sync::Arc;
7
8use super::OutputChannelManager::OutputChannelManager;
9use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError};
10
11/// Creates an effect that, when executed, will close the view of the specified
12/// output channel in the UI.
13///
14/// This does not dispose of the channel or its content; it can be revealed
15/// again later. It uses the `OutputChannelManager` capability from the
16/// environment.
17///
18/// # Parameters
19/// * `ChannelIdentifier`: The unique ID of the target channel.
20///
21/// # Returns
22/// An `ActionEffect` that resolves to `()` on success.
23pub fn CloseOutputChannelView(
24 ChannelIdentifier:String,
25) -> ActionEffect<Arc<dyn OutputChannelManager>, CommonError, ()> {
26 ActionEffect::New(Arc::new(move |Manager:Arc<dyn OutputChannelManager>| {
27 let IdentifierClone = ChannelIdentifier.clone();
28
29 Box::pin(async move { Manager.Close(IdentifierClone).await })
30 }))
31}