Common/IPC/
SendNotificationToSideCar.rs

1//! # SendNotificationToSideCar Effect
2//!
3//! Defines the `ActionEffect` for sending a fire-and-forget notification to a
4//! sidecar process.
5
6use std::sync::Arc;
7
8use serde_json::Value;
9
10use super::IPCProvider::IPCProvider;
11use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError};
12
13/// Creates an effect that, when executed, will send a fire-and-forget
14/// notification to a specified sidecar process.
15///
16/// It uses the `IPCProvider` capability from the environment to perform the
17/// actual IPC send operation. Unlike `SendRequestToSideCar`, this effect does
18/// not wait for or expect a response.
19///
20/// # Parameters
21///
22/// * `SideCarIdentifier`: The unique ID of the target sidecar process.
23/// * `Method`: The name of the notification method to be invoked on the
24///   sidecar.
25/// * `Parameters`: A `serde_json::Value` containing the parameters for the
26///   notification.
27///
28/// # Returns
29///
30/// An `ActionEffect` that resolves to `()` on success.
31pub fn SendNotificationToSideCar(
32	SideCarIdentifier:String,
33
34	Method:String,
35
36	Parameters:Value,
37) -> ActionEffect<Arc<dyn IPCProvider>, CommonError, ()> {
38	ActionEffect::New(Arc::new(move |Provider:Arc<dyn IPCProvider>| {
39		let SideCarIdentifierClone = SideCarIdentifier.clone();
40
41		let MethodClone = Method.clone();
42
43		let ParametersClone = Parameters.clone();
44
45		Box::pin(async move {
46			Provider
47				.SendNotificationToSideCar(SideCarIdentifierClone, MethodClone, ParametersClone)
48				.await
49		})
50	}))
51}