opcua_server/subscriptions/mod.rs
1// OPCUA for Rust
2// SPDX-License-Identifier: MPL-2.0
3// Copyright (C) 2017-2022 Adam Lock
4
5use opcua_core::supported_message::SupportedMessage;
6use opcua_types::{service_types::PublishRequest, status_code::StatusCode};
7
8/// The publish request entry preserves the request_id which is part of the chunk layer but clients
9/// are fickle about receiving responses from the same as the request. Normally this is easy because
10/// request and response are synchronous, but publish requests are async, so we preserve the request_id
11/// so that later we can send out responses that have the proper req id
12#[derive(Clone)]
13pub struct PublishRequestEntry {
14 // The request id
15 pub request_id: u32,
16 // The request itself
17 pub request: PublishRequest,
18 // The result of clearing acknowledgments when the request was received.
19 pub results: Option<Vec<StatusCode>>,
20}
21
22#[derive(Clone, Debug)]
23pub struct PublishResponseEntry {
24 pub request_id: u32,
25 pub response: SupportedMessage,
26}
27
28/// This converts an OPC UA Duration into a time duration used for testing for interval elapsed
29fn duration_from_ms(d: f64) -> time::Duration {
30 // Duration is a floating point number in millis so turn to microseconds for greater accuracy
31 // 1 millisecond = 1000 microsecond
32 time::Duration::microseconds((d * 1000f64) as i64)
33}
34
35pub mod monitored_item;
36pub mod subscription;
37pub mod subscriptions;