Common/Output/
AppendToOutputChannel.rs

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