opc_da_client/lib.rs
1#![allow(unsafe_code, unreachable_pub)]
2//! # opc-da-client
3//!
4//! Backend-agnostic OPC DA client library for Rust — async, trait-based,
5//! with RAII COM guard.
6//!
7//! ## Quick Start
8//!
9//! ```no_run
10//! # use anyhow::Result;
11//! use opc_da_client::{ComGuard, OpcDaWrapper, OpcProvider};
12//!
13//! # #[tokio::main]
14//! # async fn main() -> Result<()> {
15//! let _guard = ComGuard::new()?;
16//! let client = OpcDaWrapper::default();
17//! let servers = client.list_servers("localhost").await?;
18//! # Ok(())
19//! # }
20//! ```
21//!
22//! ## Feature Flags
23//!
24//! | Flag | Default | Effect |
25//! |------|---------|--------|
26//! | `opc-da-backend` | ✅ | Native OPC DA backend via `windows-rs` |
27//! | `test-support` | ❌ | Enables `MockOpcProvider` via `mockall` |
28//!
29//! ## Platform
30//!
31//! **Windows only** — OPC DA is built on COM/DCOM.
32
33mod com_guard;
34mod helpers;
35mod provider;
36
37#[cfg(feature = "opc-da-backend")]
38#[allow(warnings)]
39mod bindings;
40
41#[cfg(feature = "opc-da-backend")]
42#[allow(warnings)]
43mod opc_da;
44
45#[cfg(feature = "opc-da-backend")]
46mod backend;
47
48// Stable public API
49pub use com_guard::ComGuard;
50pub use helpers::{format_hresult, friendly_com_hint};
51pub use provider::{OpcProvider, OpcValue, TagValue, WriteResult};
52
53// Backend re-exports (conditional)
54#[cfg(feature = "opc-da-backend")]
55pub use backend::{connector::ComConnector, opc_da::OpcDaWrapper};
56
57// Test support re-export
58#[cfg(feature = "test-support")]
59pub use provider::MockOpcProvider;