Common/Output/
ClearOutputChannel.rs

1//! # ClearOutputChannel Effect
2//!
3//! Defines the `ActionEffect` for clearing all text from an 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 clear the entire buffer of the
11/// specified output channel.
12///
13/// It uses the `OutputChannelManager` capability from the environment.
14///
15/// # Parameters
16/// * `ChannelIdentifier`: The unique ID of the target channel.
17///
18/// # Returns
19/// An `ActionEffect` that resolves to `()` on success.
20pub fn ClearOutputChannel(ChannelIdentifier:String) -> ActionEffect<Arc<dyn OutputChannelManager>, CommonError, ()> {
21	ActionEffect::New(Arc::new(move |Manager:Arc<dyn OutputChannelManager>| {
22		let IdentifierClone = ChannelIdentifier.clone();
23
24		Box::pin(async move { Manager.Clear(IdentifierClone).await })
25	}))
26}