Conversation
WalkthroughThis update introduces three new Rust crates— Changes
Sequence Diagram(s)sequenceDiagram
participant Client as opc_da (client)
participant COMN as opc_comn_bindings
participant DA as opc_da_bindings
Client->>COMN: Use IOPCCommon, IOPCServerList interfaces
Client->>DA: Use DA-specific interfaces only
sequenceDiagram
participant Build as Cargo Build
participant AE as opc_ae_bindings
participant COMN as opc_comn_bindings
participant HDA as opc_hda_bindings
Build->>AE: Run build.rs (bindgen on OPCAE.winmd)
Build->>COMN: Run build.rs (bindgen on OPCCOMN.winmd)
Build->>HDA: Run build.rs (bindgen on OPCHDA.winmd)
AE->>AE: Generate Rust bindings from WinMD
COMN->>COMN: Generate Rust bindings from WinMD
HDA->>HDA: Generate Rust bindings from WinMD
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (13)
opc_comn_bindings/.metadata/.gitignore (1)
1-2: Use directory-only ignore patterns to avoid accidental file matchesPrefixing with a trailing slash (
/bin/,/obj/) makes it clear you intend to ignore directories, not any file whose name merely contains “bin” or “obj”.-bin -obj +/bin/ +/obj/opc_comn_bindings/.metadata/main.cpp (1)
1-3: Add a short comment clarifying the stub’s purposeA one-liner explaining that this TU exists solely for winmd generation will prevent future confusion and accidental removal.
+#ifdef _MSC_VER +// Stub translation unit required by generate.proj to produce OPCCOMN.winmd. +#endif #include <windows.h> #include "opccomn.h"opc_ae_bindings/.metadata/main.cpp (1)
1-3: Mirror explanatory comment for consistency across binding cratesReplicate the clarification comment added to the COMN stub to keep all metadata TUs self-documenting.
+#ifdef _MSC_VER +// Stub TU for winmd generation (OPC AE interfaces). +#endif #include <windows.h> #include "opc_ae.h"opc_hda_bindings/.metadata/main.cpp (1)
1-3: Consistency: add purpose comment to HDA stub as wellSame rationale as previous files; promotes maintainability.
+#ifdef _MSC_VER +// Stub TU for winmd generation (OPC HDA interfaces). +#endif #include <windows.h> #include "opchda.h"opc_ae_bindings/src/lib.rs (1)
1-3: Consider exposing crate-level documentation
Adding a short//!-level comment describing the purpose of the crate and how the generated bindings are produced will greatly improve discoverability on docs.rs.+//! Rust bindings for OPC AE COM interfaces generated from `OPCAE.winmd`. +//! The bindings are code-generated at build time; see the crate README +//! for regeneration instructions.opc_hda_bindings/src/lib.rs (1)
1-3: Same docstring recommendation as for AE bindings
Replicate a crate-level doc comment to explain purpose and generation process.opc_hda_bindings/README.md (1)
5-10: Replace TODO with a minimal working example
A concrete snippet helps users verify the crate is wired correctly. Example:-```rust -// TODO -``` +```rust +use opc_hda_bindings::*; + +fn main() { + // Obtain `IOPCHDA_SyncRead` from your COM server here… + // let sync_read: IOPCHDA_SyncRead = …; + // println!("Connected to OPC-HDA server: {:?}", sync_read); +} +```opc_comn_bindings/README.md (1)
5-10: Provide a runnable snippet for Common bindings
Showing a simple COM initialisation + interface acquisition pattern will make the docs much more useful.-```rust -// TODO -``` +```rust +use opc_comn_bindings::*; +use windows::Win32::{System::Com::*, System::Ole::CLSCTX_INPROC_SERVER}; + +fn main() -> windows::core::Result<()> { + unsafe { CoInitializeEx(None, COINIT_MULTITHREADED)? }; + // Example: create the OPCEnum CLSID and query `IOPCServerList` + let enum_manager: IOPCServerList = CoCreateInstance(&CLSID_OpcServerList, None, CLSCTX_INPROC_SERVER)?; + println!("Found {} OPC servers", enum_manager.EnumerateClassesOfCategories()?.len()); + Ok(()) +} +```opc_ae_bindings/README.md (1)
7-9: Address the TODO for example code.Consider adding a basic usage example to help users understand how to use the OPC AE bindings.
Would you like me to help generate a basic example once the crate API is stabilized?
opc_ae_bindings/Cargo.toml (1)
5-5: Description copy-paste error (“Historical Data Access” vs AE)The crate is
opc_ae_bindings; the description still says Historical Data Access. Update to “OPC Alarms & Events bindings” to avoid confusion on crates.io.opc_ae_bindings/.metadata/generate.proj (1)
4-6: Hard-coded0.0.0.1WinMD version – consider deriving from crate versionTiny, but keeping metadata and crate versions in sync helps downstream tooling. You can pass
$(PackageVersion)here to avoid manual updates.opc_ae_bindings/build.rs (1)
5-18: Provide actionable error context instead of bareunwrap()Surfacing bindgen failures with context accelerates debugging.
-]) - .unwrap(); +]) + .expect("windows-bindgen failed to generate OPC AE bindings");opc_ae_bindings/.metadata/opc_ae.idl (1)
383-384: String attribute placement is inconsistent with other array parameters.In the version 2 interfaces, the
[string]attribute is placed within the size_is attribute (e.g.,[in, string, size_is(dwNumAreas)]), while in the base interfaces, string parameters use just[in, string]. This inconsistency doesn't affect functionality but could be standardized for clarity.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (39)
Cargo.toml(1 hunks)opc_ae_bindings/.gitignore(1 hunks)opc_ae_bindings/.metadata/.gitignore(1 hunks)opc_ae_bindings/.metadata/generate.proj(1 hunks)opc_ae_bindings/.metadata/main.cpp(1 hunks)opc_ae_bindings/.metadata/opc_ae.idl(1 hunks)opc_ae_bindings/Cargo.toml(1 hunks)opc_ae_bindings/README.md(1 hunks)opc_ae_bindings/build.rs(1 hunks)opc_ae_bindings/src/bindings.rs(1 hunks)opc_ae_bindings/src/lib.rs(1 hunks)opc_comn_bindings/.gitignore(1 hunks)opc_comn_bindings/.metadata/.gitignore(1 hunks)opc_comn_bindings/.metadata/generate.proj(1 hunks)opc_comn_bindings/.metadata/main.cpp(1 hunks)opc_comn_bindings/Cargo.toml(1 hunks)opc_comn_bindings/README.md(1 hunks)opc_comn_bindings/build.rs(1 hunks)opc_comn_bindings/src/bindings.rs(1 hunks)opc_comn_bindings/src/lib.rs(1 hunks)opc_da/Cargo.toml(2 hunks)opc_da/src/client/traits/client.rs(1 hunks)opc_da/src/client/traits/common.rs(1 hunks)opc_da/src/client/v2/mod.rs(3 hunks)opc_da/src/client/v3/mod.rs(3 hunks)opc_da/src/server/com/server.rs(2 hunks)opc_da_bindings/.metadata/generate.proj(1 hunks)opc_da_bindings/.metadata/main.cpp(0 hunks)opc_da_bindings/Cargo.toml(2 hunks)opc_da_bindings/src/bindings.rs(0 hunks)opc_hda_bindings/.gitignore(1 hunks)opc_hda_bindings/.metadata/.gitignore(1 hunks)opc_hda_bindings/.metadata/generate.proj(1 hunks)opc_hda_bindings/.metadata/main.cpp(1 hunks)opc_hda_bindings/.metadata/opchda.idl(1 hunks)opc_hda_bindings/Cargo.toml(1 hunks)opc_hda_bindings/README.md(1 hunks)opc_hda_bindings/build.rs(1 hunks)opc_hda_bindings/src/lib.rs(1 hunks)
💤 Files with no reviewable changes (2)
- opc_da_bindings/.metadata/main.cpp
- opc_da_bindings/src/bindings.rs
🧰 Additional context used
🧠 Learnings (15)
📓 Common learnings
Learnt from: Ronbb
PR: Ronbb/rust_opc#11
File: opc_da/src/client/unified/group.rs:97-206
Timestamp: 2024-12-23T09:19:11.720Z
Learning: In a future pull request, remind Ronbb about the refactoring suggestion to extract common callback handling code into a helper function.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
opc_da/src/client/traits/common.rs (10)
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/traits/group.rs:1-122
Timestamp: 2024-12-02T14:43:35.670Z
Learning: In `opc_da/src/traits/group.rs`, the `GroupTrait` trait contains only method declarations without implementations.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/tests.rs:8-35
Timestamp: 2024-12-11T01:49:14.219Z
Learning: In the file `opc_da/src/client/tests.rs`, do not add retry logic in test functions as per the user's preference.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/traits/async_io2.rs:94-95
Timestamp: 2024-12-11T01:29:33.264Z
Learning: In `AsyncIo2Trait` within `opc_da/src/client/traits/async_io2.rs`, when directly returning a `Result` from a method like `Refresh2`, it's acceptable to return the result as is without additional wrapping.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/v3/mod.rs:9-15
Timestamp: 2024-12-10T14:03:29.606Z
Learning: In `windows-rs`, COM interfaces implement `IUnknown`, which automatically calls `Release` when dropped. Therefore, it's unnecessary to manually implement the `Drop` trait to release COM interfaces in structs that hold COM interfaces.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/unified/group.rs:28-39
Timestamp: 2024-12-10T13:51:14.061Z
Learning: In the `add_items` method in `opc_da/src/client/unified/group.rs`, the OPC DA protocol guarantees that the `results` and `errors` arrays returned will always be of the same length, so additional validation for array length mismatch is not necessary.
Learnt from: Ronbb
PR: Ronbb/rust_opc#10
File: opc_da/src/client/iterator.rs:114-114
Timestamp: 2024-12-13T18:47:42.521Z
Learning: In `opc_da/src/client/iterator.rs`, when initializing the `cache` array in `GroupIterator`, use `cache: [const { None }; 16]` instead of `cache: [None; 16]` because Flipper requires this change.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/utils.rs:61-87
Timestamp: 2024-11-28T15:39:26.903Z
Learning: In this codebase, all data copying functions should use COM. Non-COM functions like `copy_to_pointer` are unnecessary and should be omitted.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/v3/mod.rs:67-78
Timestamp: 2024-12-10T14:06:24.207Z
Learning: In windows-rs, COM interfaces implement the `Drop` trait via `IUnknown`, automatically releasing resources when they go out of scope, so manual implementation of `Drop` for structs holding COM interfaces is unnecessary.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/tests.rs:0-0
Timestamp: 2024-12-11T01:25:38.423Z
Learning: In Rust OPC DA client tests, resources like groups do not require explicit cleanup as they will be released after the OPC DA server disconnects.
opc_hda_bindings/README.md (1)
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
opc_hda_bindings/src/lib.rs (1)
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/traits/group.rs:1-122
Timestamp: 2024-12-02T14:43:35.670Z
Learning: In `opc_da/src/traits/group.rs`, the `GroupTrait` trait contains only method declarations without implementations.
opc_comn_bindings/README.md (1)
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
opc_da/src/client/traits/client.rs (7)
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/traits/server.rs:14-16
Timestamp: 2024-11-28T15:30:27.048Z
Learning: The `set_client_name` method in the `ServerTrait` does not require a length constraint on the client name, as the OPC DA specification and COM interface do not impose a maximum length.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/traits/async_io2.rs:94-95
Timestamp: 2024-12-11T01:29:33.264Z
Learning: In `AsyncIo2Trait` within `opc_da/src/client/traits/async_io2.rs`, when directly returning a `Result` from a method like `Refresh2`, it's acceptable to return the result as is without additional wrapping.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/traits/item_mgt.rs:191-194
Timestamp: 2024-12-10T03:00:26.689Z
Learning: In `opc_da/src/client/traits/item_mgt.rs`, the `CreateEnumerator` method returns a `Result`, so there is no need to handle `None` values.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/traits/group.rs:1-122
Timestamp: 2024-12-02T14:43:35.670Z
Learning: In `opc_da/src/traits/group.rs`, the `GroupTrait` trait contains only method declarations without implementations.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/tests.rs:0-0
Timestamp: 2024-12-11T01:25:38.423Z
Learning: In Rust OPC DA client tests, resources like groups do not require explicit cleanup as they will be released after the OPC DA server disconnects.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/v3/mod.rs:67-78
Timestamp: 2024-12-10T14:06:24.207Z
Learning: In windows-rs, COM interfaces implement the `Drop` trait via `IUnknown`, automatically releasing resources when they go out of scope, so manual implementation of `Drop` for structs holding COM interfaces is unnecessary.
opc_comn_bindings/src/lib.rs (1)
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/traits/group.rs:1-122
Timestamp: 2024-12-02T14:43:35.670Z
Learning: In `opc_da/src/traits/group.rs`, the `GroupTrait` trait contains only method declarations without implementations.
opc_da/Cargo.toml (1)
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
opc_hda_bindings/Cargo.toml (1)
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
opc_comn_bindings/Cargo.toml (1)
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
opc_da/src/server/com/server.rs (4)
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/v3/mod.rs:9-15
Timestamp: 2024-12-10T14:03:29.606Z
Learning: In `windows-rs`, COM interfaces implement `IUnknown`, which automatically calls `Release` when dropped. Therefore, it's unnecessary to manually implement the `Drop` trait to release COM interfaces in structs that hold COM interfaces.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/v3/mod.rs:67-78
Timestamp: 2024-12-10T14:06:24.207Z
Learning: In windows-rs, COM interfaces implement the `Drop` trait via `IUnknown`, automatically releasing resources when they go out of scope, so manual implementation of `Drop` for structs holding COM interfaces is unnecessary.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/traits/group.rs:1-122
Timestamp: 2024-12-02T14:43:35.670Z
Learning: In `opc_da/src/traits/group.rs`, the `GroupTrait` trait contains only method declarations without implementations.
opc_da/src/client/v2/mod.rs (8)
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/traits/async_io2.rs:94-95
Timestamp: 2024-12-11T01:29:33.264Z
Learning: In `AsyncIo2Trait` within `opc_da/src/client/traits/async_io2.rs`, when directly returning a `Result` from a method like `Refresh2`, it's acceptable to return the result as is without additional wrapping.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/traits/group.rs:1-122
Timestamp: 2024-12-02T14:43:35.670Z
Learning: In `opc_da/src/traits/group.rs`, the `GroupTrait` trait contains only method declarations without implementations.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/tests.rs:0-0
Timestamp: 2024-12-11T01:25:38.423Z
Learning: In Rust OPC DA client tests, resources like groups do not require explicit cleanup as they will be released after the OPC DA server disconnects.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/traits/server.rs:14-16
Timestamp: 2024-11-28T15:30:27.048Z
Learning: The `set_client_name` method in the `ServerTrait` does not require a length constraint on the client name, as the OPC DA specification and COM interface do not impose a maximum length.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/tests.rs:8-35
Timestamp: 2024-12-11T01:49:14.219Z
Learning: In the file `opc_da/src/client/tests.rs`, do not add retry logic in test functions as per the user's preference.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/v3/mod.rs:9-15
Timestamp: 2024-12-10T14:03:29.606Z
Learning: In `windows-rs`, COM interfaces implement `IUnknown`, which automatically calls `Release` when dropped. Therefore, it's unnecessary to manually implement the `Drop` trait to release COM interfaces in structs that hold COM interfaces.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/v3/mod.rs:67-78
Timestamp: 2024-12-10T14:06:24.207Z
Learning: In windows-rs, COM interfaces implement the `Drop` trait via `IUnknown`, automatically releasing resources when they go out of scope, so manual implementation of `Drop` for structs holding COM interfaces is unnecessary.
opc_da/src/client/v3/mod.rs (8)
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/traits/async_io2.rs:94-95
Timestamp: 2024-12-11T01:29:33.264Z
Learning: In `AsyncIo2Trait` within `opc_da/src/client/traits/async_io2.rs`, when directly returning a `Result` from a method like `Refresh2`, it's acceptable to return the result as is without additional wrapping.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/traits/group.rs:1-122
Timestamp: 2024-12-02T14:43:35.670Z
Learning: In `opc_da/src/traits/group.rs`, the `GroupTrait` trait contains only method declarations without implementations.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/tests.rs:8-35
Timestamp: 2024-12-11T01:49:14.219Z
Learning: In the file `opc_da/src/client/tests.rs`, do not add retry logic in test functions as per the user's preference.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/tests.rs:0-0
Timestamp: 2024-12-11T01:25:38.423Z
Learning: In Rust OPC DA client tests, resources like groups do not require explicit cleanup as they will be released after the OPC DA server disconnects.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/traits/server.rs:14-16
Timestamp: 2024-11-28T15:30:27.048Z
Learning: The `set_client_name` method in the `ServerTrait` does not require a length constraint on the client name, as the OPC DA specification and COM interface do not impose a maximum length.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/v3/mod.rs:9-15
Timestamp: 2024-12-10T14:03:29.606Z
Learning: In `windows-rs`, COM interfaces implement `IUnknown`, which automatically calls `Release` when dropped. Therefore, it's unnecessary to manually implement the `Drop` trait to release COM interfaces in structs that hold COM interfaces.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/v3/mod.rs:67-78
Timestamp: 2024-12-10T14:06:24.207Z
Learning: In windows-rs, COM interfaces implement the `Drop` trait via `IUnknown`, automatically releasing resources when they go out of scope, so manual implementation of `Drop` for structs holding COM interfaces is unnecessary.
opc_comn_bindings/src/bindings.rs (4)
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/v3/mod.rs:67-78
Timestamp: 2024-12-10T14:06:24.207Z
Learning: In windows-rs, COM interfaces implement the `Drop` trait via `IUnknown`, automatically releasing resources when they go out of scope, so manual implementation of `Drop` for structs holding COM interfaces is unnecessary.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/v3/mod.rs:9-15
Timestamp: 2024-12-10T14:03:29.606Z
Learning: In `windows-rs`, COM interfaces implement `IUnknown`, which automatically calls `Release` when dropped. Therefore, it's unnecessary to manually implement the `Drop` trait to release COM interfaces in structs that hold COM interfaces.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/traits/group.rs:1-122
Timestamp: 2024-12-02T14:43:35.670Z
Learning: In `opc_da/src/traits/group.rs`, the `GroupTrait` trait contains only method declarations without implementations.
opc_ae_bindings/src/bindings.rs (3)
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/v3/mod.rs:67-78
Timestamp: 2024-12-10T14:06:24.207Z
Learning: In windows-rs, COM interfaces implement the `Drop` trait via `IUnknown`, automatically releasing resources when they go out of scope, so manual implementation of `Drop` for structs holding COM interfaces is unnecessary.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/v3/mod.rs:9-15
Timestamp: 2024-12-10T14:03:29.606Z
Learning: In `windows-rs`, COM interfaces implement `IUnknown`, which automatically calls `Release` when dropped. Therefore, it's unnecessary to manually implement the `Drop` trait to release COM interfaces in structs that hold COM interfaces.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
🧬 Code Graph Analysis (4)
opc_comn_bindings/build.rs (2)
opc_ae_bindings/build.rs (1)
main(1-19)opc_hda_bindings/build.rs (1)
main(1-19)
opc_hda_bindings/build.rs (2)
opc_ae_bindings/build.rs (1)
main(1-19)opc_comn_bindings/build.rs (1)
main(1-19)
opc_ae_bindings/build.rs (2)
opc_comn_bindings/build.rs (1)
main(1-19)opc_hda_bindings/build.rs (1)
main(1-19)
opc_da/src/client/v3/mod.rs (1)
opc_da/src/client/v2/mod.rs (14)
interface(59-61)interface(65-67)interface(71-75)interface(79-81)interface(85-92)interface(96-103)interface(147-149)interface(153-155)interface(159-166)interface(170-172)interface(176-183)interface(187-189)interface(193-197)interface(201-208)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: analyzing
- GitHub Check: build
🔇 Additional comments (29)
opc_hda_bindings/.metadata/.gitignore (1)
1-2: Build artifacts correctly excludedIgnoring
binandobjkeeps the repo clean and mirrors the pattern used in the other binding crates.opc_da/src/client/traits/common.rs (1)
1-1: Confirm no stale references to the old binding path
I ranrg 'opc_da_bindings::IOPCCommon' -nand found no matches. To be certain every caller has been migrated toopc_comn_bindings::IOPCCommon, please also perform a broad search foropc_da_bindingsacross the repository.opc_ae_bindings/.gitignore (1)
1-1: 👍 Target directory ignoredMatches the rest of the workspace setup.
opc_hda_bindings/.gitignore (1)
1-1: Consistent.gitignorepattern
/targetexclusion aligns with sibling crates.opc_ae_bindings/.metadata/.gitignore (1)
1-2: Metadata build outputs correctly ignoredPrevents polluting VCS with MSBuild
bin/objfolders.opc_comn_bindings/.gitignore (1)
1-1: Looks good – matches Cargo’s default ignoreNo issues spotted.
opc_da_bindings/.metadata/generate.proj (1)
9-15: Verify build succeeds after droppingopccomnartifacts
opccomn.idl/hwere removed from the inputs. Please re-build the DA bindings in isolation (and in CI) to ensure no transitive include inopcda.idlor the generated code still references the Common headers.
If the build still pulls inopccomn.h, add an explicit<AdditionalIncludes>entry or restore the item in this project; otherwise the WinMD generator will fail late in the pipeline.opc_da/Cargo.toml (2)
3-3: LGTM! Version bump is appropriate.The version increment from 0.3.0 to 0.3.1 aligns with the addition of new dependencies and structural changes.
17-18: Dependencies correctly updated for the new crate structure.The addition of
opc_comn_bindingsand version bump ofopc_da_bindingsare consistent with moving common OPC interfaces to the dedicatedopc_comn_bindingscrate.opc_ae_bindings/README.md (1)
11-18: Good documentation for metadata rebuild process.The instructions for rebuilding metadata are clear and helpful for development.
opc_da_bindings/Cargo.toml (2)
3-3: Version bump appropriately reflects the interface changes.The increment to 0.3.1 is suitable given the removal of common OPC interfaces that moved to
opc_comn_bindings.
17-22: Excellent adoption of workspace dependency management.Using
workspace = truefor the windows ecosystem crates promotes consistency and simplifies dependency management across the workspace.opc_da/src/client/traits/client.rs (1)
24-24: All OPC common interfaces consistently useopc_comn_bindings
- No remaining
opc_da_bindings::IOPC*references found- Verified
opc_comn_bindings::IOPCServerList,IOPCCommon,IOPCEnumGUID,IOPCServerList2, andIOPCShutdownusages in both server and client modulesApproving the change.
opc_comn_bindings/src/lib.rs (1)
1-3: Clean and conventional crate structure.The module declaration and re-export pattern is standard for Rust binding crates, providing a clean public API surface.
opc_ae_bindings/Cargo.toml (1)
4-4:edition = "2024"requires nightly – verify tool-chain supportThe 2024 edition has not yet shipped on stable. Building the crate on the default stable channel will fail.
Pin to2021(or add a workspace-level override + CI job that uses nightly) to avoid surprising consumers.opc_hda_bindings/Cargo.toml (1)
4-4: Nightly-only 2024 edition – same concern as AE crateSee previous comment; keep editions consistent across the workspace and usable on stable.
Cargo.toml (1)
11-20: Version skew betweenwindowsandwindows-bindgen
windowsis pinned to 0.61.x whilewindows-bindgenis 0.62.x. Mixing major/minor versions can lead to ABI/metadata mismatches (0.62 bumped metadata format).
Align them to the same minor (e.g. 0.62.*) unless you have a specific reason.opc_comn_bindings/build.rs (1)
1-19: LGTM!The build script follows the established pattern used by other OPC binding crates and correctly generates Rust bindings from the Windows metadata file.
opc_hda_bindings/.metadata/generate.proj (1)
1-17: LGTM!The MSBuild project configuration correctly sets up Windows metadata generation for OPC HDA with appropriate SDK version, output paths, and namespace configuration.
opc_hda_bindings/build.rs (1)
1-19: LGTM!The build script correctly follows the established pattern for OPC binding generation and properly configures the bindgen parameters for OPC HDA.
opc_da/src/server/com/server.rs (2)
17-17: LGTM!Correctly updates the interface import to use the new
opc_comn_bindingscrate as part of the refactoring to separate common OPC interfaces.
125-125: LGTM!Correctly updates the trait implementation to use
opc_comn_bindings::IOPCCommon_Implwhile preserving all existing method implementations unchanged.opc_comn_bindings/.metadata/generate.proj (1)
1-17: LGTM!The MSBuild project configuration for generating OPC Common Windows metadata is properly structured and follows the established patterns.
opc_da/src/client/v2/mod.rs (1)
36-36: Correct migration to opc_comn_bindings.The changes properly update the
IOPCCommoninterface references to use the newopc_comn_bindingscrate, maintaining consistency with the workspace restructuring.Also applies to: 65-65
opc_da/src/client/v3/mod.rs (1)
34-34: Consistent migration to opc_comn_bindings.The changes correctly update the
IOPCCommoninterface references, maintaining consistency with the v2 module and the overall workspace restructuring.Also applies to: 61-61
opc_comn_bindings/src/bindings.rs (1)
1-781: Auto-generated bindings look correct.The windows-bindgen generated code properly defines all OPC Common interfaces with appropriate COM vtables and Rust trait implementations.
opc_ae_bindings/src/bindings.rs (2)
1-9: Auto-generated file looks good.The file header correctly indicates this is auto-generated by
windows-bindgen0.62.1 and includes appropriate linting exceptions for generated code.
443-454: Consider the edge case where slice length exceeds u32 range.The generated code uses
try_into().unwrap()to convert slice lengths to u32. While unlikely in practice, this could panic if the slice length exceeds u32::MAX.This is a minor concern for auto-generated code, but worth noting if the bindings are regenerated with different safety guarantees in the future.
opc_ae_bindings/.metadata/opc_ae.idl (1)
1-27: Well-structured IDL file with proper OPC Foundation header.The file includes appropriate copyright notice, disclaimer, and modification history as expected for OPC specification files.
| repository = "https://github.com/Ronbb/rust_opc" | ||
| license = "MIT" | ||
| keywords = ["ae", "bindings", "opc", "opcae"] | ||
| exclude = [".metadata/*", ".windows/*", "build.rs"] |
There was a problem hiding this comment.
Excluding build.rs breaks downstream builds
build.rs is needed at compile time but is listed in exclude. cargo publish will omit it, making the crate unbuildable for users.
-exclude = [".metadata/*", ".windows/*", "build.rs"]
+exclude = [".metadata/*", ".windows/*"]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| exclude = [".metadata/*", ".windows/*", "build.rs"] | |
| exclude = [".metadata/*", ".windows/*"] |
🤖 Prompt for AI Agents
In opc_ae_bindings/Cargo.toml at line 10, the build.rs file is incorrectly
listed in the exclude array, causing it to be omitted during cargo publish and
breaking downstream builds. Remove "build.rs" from the exclude list to ensure it
is included in the published crate and available at compile time for users.
| repository = "https://github.com/Ronbb/rust_opc" | ||
| license = "MIT" | ||
| keywords = ["bindings", "hda", "opc", "opchda"] | ||
| exclude = [".metadata/*", ".windows/*", "build.rs"] |
There was a problem hiding this comment.
build.rs excluded from package
Remove build.rs from the exclude list; otherwise the published crate will not compile.
🤖 Prompt for AI Agents
In opc_hda_bindings/Cargo.toml at line 10, the file build.rs is currently listed
in the exclude array, which prevents it from being included in the published
crate and causes compilation failures. Remove build.rs from the exclude list so
that it is packaged and available during crate compilation.
| println!("cargo:rerun-if-changed=build.rs"); | ||
| println!("cargo:rerun-if-changed=.windows/winmd/OPCAE.winmd"); |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Watch the IDL & project files for changes
If opc_ae.idl or generate.proj changes but the .winmd timestamp is stale, Cargo will not rerun this script, leading to out-of-date bindings.
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=.windows/winmd/OPCAE.winmd");
+println!("cargo:rerun-if-changed=.metadata/opc_ae.idl");
+println!("cargo:rerun-if-changed=.metadata/generate.proj");📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| println!("cargo:rerun-if-changed=build.rs"); | |
| println!("cargo:rerun-if-changed=.windows/winmd/OPCAE.winmd"); | |
| println!("cargo:rerun-if-changed=build.rs"); | |
| println!("cargo:rerun-if-changed=.windows/winmd/OPCAE.winmd"); | |
| println!("cargo:rerun-if-changed=.metadata/opc_ae.idl"); | |
| println!("cargo:rerun-if-changed=.metadata/generate.proj"); |
🤖 Prompt for AI Agents
In opc_ae_bindings/build.rs around lines 2 to 3, the build script only watches
build.rs and the .winmd file for changes, but it should also watch opc_ae.idl
and generate.proj files. Add println! statements for
"cargo:rerun-if-changed=opc_ae.idl" and "cargo:rerun-if-changed=generate.proj"
to ensure Cargo reruns the build script when these files change, preventing
stale bindings.
| // | ||
| // CONTENTS: | ||
| // | ||
| // Interface declarations for the OPC Historial Data Access specifications. |
There was a problem hiding this comment.
Fix typo in the comment.
"Historial" should be "Historical".
-// Interface declarations for the OPC Historial Data Access specifications.
+// Interface declarations for the OPC Historical Data Access specifications.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Interface declarations for the OPC Historial Data Access specifications. | |
| // Interface declarations for the OPC Historical Data Access specifications. |
🤖 Prompt for AI Agents
In opc_hda_bindings/.metadata/opchda.idl at line 6, correct the typo in the
comment by changing "Historial" to "Historical" to accurately describe the OPC
Historical Data Access specifications.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
opc_hda_bindings/README.md (1)
13-13: Correct capitalization: “PowerShell”-Open **Developer Powershell for VS2022**. +Open **Developer PowerShell for VS2022**.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
opc_ae_bindings/Cargo.toml(1 hunks)opc_ae_bindings/README.md(1 hunks)opc_comn_bindings/Cargo.toml(1 hunks)opc_hda_bindings/README.md(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- opc_comn_bindings/Cargo.toml
🚧 Files skipped from review as they are similar to previous changes (2)
- opc_ae_bindings/Cargo.toml
- opc_ae_bindings/README.md
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Ronbb
PR: Ronbb/rust_opc#11
File: opc_da/src/client/unified/group.rs:97-206
Timestamp: 2024-12-23T09:19:11.720Z
Learning: In a future pull request, remind Ronbb about the refactoring suggestion to extract common callback handling code into a helper function.
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
opc_hda_bindings/README.md (2)
Learnt from: Ronbb
PR: Ronbb/rust_opc#8
File: opc_da/src/com/server.rs:714-716
Timestamp: 2024-11-29T12:06:30.463Z
Learning: In the `opc_da/src/com/server.rs` file (Rust), the enum variant `OPC_NS_HIERARCHIAL` is correctly spelled as per the OPC specification, even though it appears misspelled.
Learnt from: Ronbb
PR: Ronbb/rust_opc#9
File: opc_da/src/client/tests.rs:0-0
Timestamp: 2024-12-11T01:25:38.423Z
Learning: In Rust OPC DA client tests, resources like groups do not require explicit cleanup as they will be released after the OPC DA server disconnects.
🪛 LanguageTool
opc_hda_bindings/README.md
[grammar] ~1-~1: Ensure spelling is correct
Context: # OPC Historial Data Access Bindings Please see docs o...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build
- GitHub Check: analyzing
| ```rust | ||
| // TODO | ||
| ``` |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Replace the TODO with a real, minimal usage example
A README without an example is hardly useful to first-time users. Consider showing the most basic task, e.g. creating a client and reading a single HDA item, even if it’s just pseudo-code.
🤖 Prompt for AI Agents
In opc_hda_bindings/README.md around lines 7 to 9, replace the placeholder TODO
comment with a real, minimal usage example demonstrating the basic functionality
of the library. Provide a concise snippet showing how to create a client and
read a single HDA item, even if it is simplified or pseudo-code, to help
first-time users understand how to use the bindings.
Summary by CodeRabbit
New Features
Refactor
Chores