Common/IPC/EstablishHostConnection.rs
1//! # EstablishHostConnection Effect
2//!
3//! Defines a convenience `ActionEffect` for establishing or confirming a
4//! connection to a sidecar process.
5
6use std::sync::Arc;
7
8use serde_json::Value;
9
10use super::SendNotificationToSideCar::SendNotificationToSideCar;
11use crate::{Effect::ActionEffect::ActionEffect, Error::CommonError::CommonError, IPC::IPCProvider::IPCProvider};
12
13/// Creates a convenience effect that can be used to perform an initial
14/// handshake or ping a sidecar process to confirm connectivity.
15///
16/// This function is a specialized wrapper around `SendNotificationToSideCar`,
17
18/// pre-filling the method name and parameters for a standard handshake
19/// notification.
20///
21/// # Parameters
22///
23/// * `SideCarIdentifier`: The unique ID of the sidecar process to connect to.
24///
25/// # Returns
26///
27/// An `ActionEffect` that resolves to `()` on success and requires the
28/// `IPCProvider` capability to be executed.
29pub fn EstablishHostConnection(SideCarIdentifier:String) -> ActionEffect<Arc<dyn IPCProvider>, CommonError, ()> {
30 SendNotificationToSideCar(SideCarIdentifier, "$InitialHandshake".to_string(), Value::Null)
31}