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 inventory;
38#[cfg(feature = "opc-da-backend")]
39mod native_browse;
40mod provider;
41
42#[cfg(feature = "opc-da-backend")]
43#[allow(warnings)]
44mod bindings;
45pub mod com_worker;
46
47#[cfg(feature = "opc-da-backend")]
48#[allow(warnings)]
49mod opc_da;
50
51#[cfg(feature = "opc-da-backend")]
52mod backend;
53
54// Stable public API
55pub use helpers::{format_hresult, friendly_com_hint, log_opc_error};
56pub use provider::{
57    BrowseCapabilities, BrowseNamespace, BrowseNode, BrowseNodeFilter, BrowseNodeKind,
58    BrowseNodeToken, BrowsePage, BrowsePageRequest, BrowsePageToken, BrowseSessionToken,
59    InventoryCompleted, InventoryControl, InventoryEntry, InventoryEvent, InventoryOptions,
60    InventoryProgress, InventoryStream, OpcProvider, OpcValue, TagValue, WriteResult,
61};
62
63#[cfg(feature = "opc-da-backend")]
64pub use opc_da::{
65    errors::{OpcError, OpcResult},
66    typedefs::{GroupHandle, ItemHandle},
67};
68
69// Backend re-exports (conditional)
70#[cfg(feature = "opc-da-backend")]
71pub use backend::{connector::ComConnector, opc_da::OpcDaClient};
72
73// Test support re-export
74#[cfg(feature = "test-support")]
75pub use provider::MockOpcProvider;