diff --git a/Cargo.lock b/Cargo.lock index 0556d063..34b1afb2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1215,6 +1215,7 @@ dependencies = [ "parking_lot", "serde", "serde_yaml", + "thiserror", "tokio", "tokio-util", "url", diff --git a/opcua-core/Cargo.toml b/opcua-core/Cargo.toml index 34bfc79b..cdb50b30 100644 --- a/opcua-core/Cargo.toml +++ b/opcua-core/Cargo.toml @@ -28,6 +28,7 @@ url = { workspace = true } opcua-types = { path = "../opcua-types" } opcua-crypto = { path = "../opcua-crypto" } +thiserror = { workspace = true } [lints.rust] diff --git a/opcua-core/src/errors.rs b/opcua-core/src/errors.rs new file mode 100644 index 00000000..6c9a854c --- /dev/null +++ b/opcua-core/src/errors.rs @@ -0,0 +1,17 @@ +// OPCUA for Rust +// SPDX-License-Identifier: MPL-2.0 + +//! Rust OpcUa specific errors + +use opcua_types::VariantScalarTypeId; +use thiserror::Error; + +/// Rust OpcUa specific errors +#[allow(missing_docs)] +#[derive(Error, Debug)] +pub enum OpcUAError { + #[error("Received an unexpected variant type")] + UnexpectedVariantType(Option), + #[error("The requested namespace does not exists")] + NamespaceDoesNotExist(String), +} diff --git a/opcua-core/src/lib.rs b/opcua-core/src/lib.rs index 14f8ad6e..a4b28a32 100644 --- a/opcua-core/src/lib.rs +++ b/opcua-core/src/lib.rs @@ -64,6 +64,7 @@ pub mod constants { pub mod comms; pub mod config; +pub mod errors; pub mod handle; pub mod messages; diff --git a/samples/client.conf b/samples/client.conf index 4f87d09a..ea41b25c 100644 --- a/samples/client.conf +++ b/samples/client.conf @@ -9,13 +9,6 @@ verify_server_certs: true pki_dir: ./pki preferred_locales: [] default_endpoint: sample_none -user_tokens: - sample_user: - user: sample1 - password: sample1pwd - sample_user2: - user: sample2 - password: sample2pwd endpoints: sample_basic128rsa15: url: opc.tcp://127.0.0.1:4855/ @@ -37,6 +30,14 @@ endpoints: security_policy: None security_mode: None user_token_id: ANONYMOUS +user_tokens: + sample_user: + user: sample1 + password: sample1pwd + sample_user2: + user: sample2 + password: sample2pwd +channel_lifetime: 60000 decoding_options: max_message_size: 327675 max_chunk_count: 5 @@ -65,10 +66,9 @@ publish_timeout: min_publish_interval: secs: 0 nanos: 100000000 -session_timeout: 60000 performance: ignore_clock_skew: false recreate_monitored_items_chunk: 1000 -session_name: Rust OPC UA Client -channel_lifetime: 60000 recreate_subscriptions: true +session_name: Rust OPC UA Client +session_timeout: 60000