Skip to main content

opc_da_client/
lib.rs

1#![allow(unsafe_code, unreachable_pub)]
2#![doc = include_str!("../README.md")]
3//! # opc-da-client
4//!
5//! Backend-agnostic OPC DA client library for Rust — async, trait-based,
6//! with transparent COM management.
7//!
8//! ## Quick Start
9//!
10//! ```no_run
11//! # use anyhow::Result;
12//! use opc_da_client::{OpcDaClient, OpcProvider};
13//!
14//! # #[tokio::main]
15//! # async fn main() -> Result<()> {
16//! let client = OpcDaClient::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;
34pub use com_guard::ComGuard;
35mod helpers;
36#[cfg(feature = "opc-da-backend")]
37mod native_browse;
38mod provider;
39
40#[cfg(feature = "opc-da-backend")]
41#[allow(warnings)]
42mod bindings;
43pub mod com_worker;
44
45#[cfg(feature = "opc-da-backend")]
46#[allow(warnings)]
47mod opc_da;
48
49#[cfg(feature = "opc-da-backend")]
50mod backend;
51
52// Stable public API
53pub use helpers::{format_hresult, friendly_com_hint, log_opc_error};
54pub use provider::{
55    BrowseCapabilities, BrowseNamespace, BrowseNode, BrowseNodeFilter, BrowseNodeKind,
56    BrowseNodeToken, BrowsePage, BrowsePageRequest, BrowsePageToken, BrowseSessionToken,
57    OpcProvider, OpcValue, TagValue, WriteResult,
58};
59
60#[cfg(feature = "opc-da-backend")]
61pub use opc_da::{
62    errors::{OpcError, OpcResult},
63    typedefs::{GroupHandle, ItemHandle},
64};
65
66// Backend re-exports (conditional)
67#[cfg(feature = "opc-da-backend")]
68pub use backend::{connector::ComConnector, opc_da::OpcDaClient};
69
70// Test support re-export
71#[cfg(feature = "test-support")]
72pub use provider::MockOpcProvider;