Skip to main content

bhtune_driver/
lib.rs

1//! `bhtune-driver` — the extensibility seam.
2//!
3//! Defines a single async [`Driver`] trait abstracting all tag I/O (`read`/`write`/
4//! browse/search) so `bhtune-core`'s tuning engine never knows what it is talking to. Three
5//! implementations exist:
6//!
7//! - [`opcda`]: the primary driver for v1 ([`OpcDaDriver`]), over the `opcda-bridge`
8//!   crates.io dependency (Windows OPC DA via a network gateway — no COM/DCOM dependency in
9//!   this process). Also home to [`get_opcda_gateway_info`], [`check_gateway_compatibility`],
10//!   and [`list_opcda_servers`], standalone pre-connection functions for gateway diagnostics,
11//!   gateway protocol compatibility checks, and OPC DA server discovery (see those functions'
12//!   doc comments for why they aren't `Driver`/`OpcDaDriver` methods).
13//! - [`simulator`]: an in-process FOPDT (first-order-plus-dead-time) process model
14//!   ([`SimulatorDriver`]), used for fully automated E2E tests on CI (no Windows, no
15//!   Kepware, no external process) and as a demo mode. Also home to [`VirtualPid`], a
16//!   standalone PID controller for closed-loop validation/demos.
17//! - [`replay`]: feeds a recorded golden-master trace ([`ReplayDriver`]) back through the
18//!   engine, for regression validation — see that module's doc comment for why this
19//!   complements, rather than duplicates, the pure-engine parity test in `bhtune-core`.
20//!
21//! `OpcUaDriver` and `ModbusDriver` are roadmap items
22//! (see `docs/roadmap.md`) that can slot in without requiring changes to `bhtune-core`.
23//!
24//! - [`driver`] — the [`Driver`] trait itself.
25//! - [`types`] — the plain data types ([`TagId`], [`TagValue`], [`TagWrite`],
26//!   [`WriteOutcome`], browse-page, capability, and search types) that cross the trait boundary.
27//! - [`error`] — the crate's error type, [`DriverError`].
28//! - [`opcda`] — [`OpcDaDriver`], the OPC DA implementation, gateway diagnostics, gateway
29//!   compatibility checks ([`OpcDaGatewayCompatibility`]), and [`list_opcda_servers`].
30//! - [`simulator`] — [`SimulatorDriver`], [`FopdtProcess`]/[`FopdtConfig`], and
31//!   [`VirtualPid`]/[`VirtualPidConfig`].
32//! - [`replay`] — [`ReplayDriver`], [`ReplaySample`], and [`RecordedWrite`].
33
34#![cfg_attr(
35    test,
36    allow(
37        clippy::unwrap_used,
38        clippy::expect_used,
39        clippy::panic,
40        reason = "unit tests may use unwrap, expect, and panic; production code must return typed errors"
41    )
42)]
43
44pub mod driver;
45pub mod error;
46pub mod opcda;
47pub mod readonly;
48pub mod replay;
49pub mod simulator;
50pub mod types;
51
52pub use driver::Driver;
53pub use error::{DriverError, DriverResult};
54pub use opcda::{
55    DEFAULT_INDEX_SEARCH_MAX_RESULTS, DEFAULT_PAGE_SIZE, DEFAULT_SEARCH_MAX_RESULTS,
56    OpcDaCompatibilitySource, OpcDaCompatibilityStatus, OpcDaDriver, OpcDaFeatureCompatibility,
57    OpcDaFeatureCompatibilityStatus, OpcDaGatewayCompatibility, OpcDaGatewayFeature,
58    OpcDaGatewayFeatureSupport, OpcDaGatewayInfo, OpcDaProtocolRange, check_gateway_compatibility,
59    close_opcda_browse_session, get_opcda_gateway_info, list_opcda_servers,
60};
61pub use readonly::ReadOnlyDriver;
62pub use replay::{RecordedWrite, ReplayDriver, ReplaySample, ReplayTraceExhausted};
63pub use simulator::{FopdtConfig, FopdtProcess, SimulatorDriver, VirtualPid, VirtualPidConfig};
64pub use types::{
65    BrowseBreadcrumb, BrowseNode, BrowseNodeKind, BrowsePage, BrowsePageRequest, BrowseSource,
66    DriverCapabilities, IndexSchedulerDiagnostics, IndexedSearchMatch, IndexedSearchProgress,
67    NamespaceOrganization, Quality, SearchCompleted, SearchEvent, SearchIndexControlAction,
68    SearchIndexRequest, SearchIndexResponse, SearchIndexState, SearchIndexStatus, SearchMatch,
69    SearchMatchMode, SearchProgress, SearchRequest, TagId, TagValue, TagWrite, WriteOutcome,
70};