Common/Output/
ReplaceOutputChannelContent.rs

1//! # ReplaceOutputChannelContent Effect
2//!
3//! Defines the `ActionEffect` for replacing the entire content of an output
4//! channel.
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 replace the entire buffer of
12/// the specified output channel with a new string.
13///
14/// It uses the `OutputChannelManager` capability from the environment.
15///
16/// # Parameters
17/// * `ChannelIdentifier`: The unique ID of the target channel.
18/// * `Value`: The new string content for the channel.
19///
20/// # Returns
21/// An `ActionEffect` that resolves to `()` on success.
22pub fn ReplaceOutputChannelContent(
23	ChannelIdentifier:String,
24
25	Value:String,
26) -> ActionEffect<Arc<dyn OutputChannelManager>, CommonError, ()> {
27	ActionEffect::New(Arc::new(move |Manager:Arc<dyn OutputChannelManager>| {
28		let IdentifierClone = ChannelIdentifier.clone();
29
30		let ValueClone = Value.clone();
31
32		Box::pin(async move { Manager.Replace(IdentifierClone, ValueClone).await })
33	}))
34}