1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
//! Rust wrapper for the [open62541](https://www.open62541.org) library.
//!
//! # Examples
//!
//! ## Connect to server
//!
//! ```no_run
//! use open62541::AsyncClient;
//!
//! # #[tokio::main(flavor = "current_thread")]
//! # async fn main() -> anyhow::Result<()> {
//! #
//! let client = AsyncClient::new(
//! "opc.tcp://opcuademo.sterfive.com:26543",
//! tokio::time::Duration::from_millis(100),
//! )?;
//! #
//! # Ok(())
//! # }
//! ```
//!
//! ## Read node's value attribute
//!
//! ```no_run
//! # use open62541::AsyncClient;
//! use open62541::ua::NodeId;
//!
//! # #[tokio::main(flavor = "current_thread")]
//! # async fn main() -> anyhow::Result<()> {
//! #
//! # let client = AsyncClient::new(
//! # "opc.tcp://opcuademo.sterfive.com:26543",
//! # tokio::time::Duration::from_millis(100),
//! # )?;
//! #
//! let node_id = NodeId::numeric(0, 2258); // Server/ServerStatus/CurrentTime
//!
//! let value = client.read_value(&node_id).await?;
//!
//! println!("Received value: {value:?}");
//! #
//! # Ok(())
//! # }
//! ```
//!
//! ## Watch node for changes in value attribute
//!
//! ```no_run
//! # use open62541::{AsyncClient, ua::NodeId};
//! #
//! # #[tokio::main(flavor = "current_thread")]
//! # async fn main() -> anyhow::Result<()> {
//! #
//! # let client = AsyncClient::new(
//! # "opc.tcp://opcuademo.sterfive.com:26543",
//! # tokio::time::Duration::from_millis(100),
//! # )?;
//! #
//! # let node_id = NodeId::numeric(0, 2258); // Server/ServerStatus/CurrentTime
//! #
//! // Create subscription that receives the updates.
//! let subscription = client.create_subscription().await?;
//! // Create monitored item to receive node updates.
//! let mut monitored_item = subscription.create_monitored_item(&node_id).await?;
//!
//! while let Some(value) = monitored_item.next().await {
//! println!("Received value: {value:?}");
//! }
//! #
//! # Ok(())
//! # }
//! ```
mod client;
mod data_type;
mod error;
mod service;
pub mod ua;
#[cfg(feature = "tokio")]
mod async_client;
#[cfg(feature = "tokio")]
mod async_monitored_item;
#[cfg(feature = "tokio")]
mod async_subscription;
#[cfg(feature = "tokio")]
mod callback;
pub use self::{
client::{Client, ClientBuilder},
data_type::DataType,
error::Error,
};
pub(crate) use self::{
data_type::{data_type, enum_variants},
service::{ServiceRequest, ServiceResponse},
};
#[cfg(feature = "tokio")]
pub use self::{
async_client::AsyncClient,
async_monitored_item::AsyncMonitoredItem,
async_subscription::AsyncSubscription,
callback::{CallbackOnce, CallbackStream},
};