1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use crate::opc_da::errors::{OpcError, OpcResult};
use windows::core::{GUID, Interface as _};
/// COM connection point container functionality.
///
/// Provides methods to establish connections between event sources
/// and event sinks in the OPC COM architecture. Used primarily for
/// handling asynchronous callbacks.
pub trait ConnectionPointContainerTrait {
fn interface(&self) -> OpcResult<&windows::Win32::System::Com::IConnectionPointContainer>;
/// Finds a connection point for a specific interface.
///
/// # Arguments
/// * `id` - GUID of the connection point interface to find
///
/// # Returns
/// Connection point interface for the specified GUID
///
/// # Safety
/// Caller must ensure:
/// - COM is properly initialized
/// - The underlying COM object is valid
///
/// # Errors
/// Returns an error if:
/// - The COM operation fails
/// - The connection point is not found
fn find_connection_point(
&self,
id: &GUID,
) -> OpcResult<windows::Win32::System::Com::IConnectionPoint> {
// SAFETY: Calling COM method FindConnectionPoint with valid IID reference.
unsafe { Ok(self.interface()?.FindConnectionPoint(id)?) }
}
fn data_callback_connection_point(
&self,
) -> OpcResult<windows::Win32::System::Com::IConnectionPoint> {
self.find_connection_point(&crate::bindings::da::IOPCDataCallback::IID)
}
/// Enumerates all available connection points.
///
/// # Returns
/// Enumerator for iterating through available connection points
///
/// # Safety
/// Caller must ensure:
/// - COM is properly initialized
/// - The underlying COM object is valid
///
/// # Errors
/// Returns an error if:
/// - The COM operation fails
/// - No connection points are available
fn enum_connection_points(
&self,
) -> OpcResult<windows::Win32::System::Com::IEnumConnectionPoints> {
// SAFETY: Calling COM method EnumConnectionPoints.
unsafe { Ok(self.interface()?.EnumConnectionPoints()?) }
}
}