From 22cf6c7e691ab6656ea0c10af7d3bef24908f2d7 Mon Sep 17 00:00:00 2001 From: Sebastian Goll Date: Thu, 19 Dec 2024 15:15:35 +0100 Subject: [PATCH] Rename methods to be consistent with open62541 names --- CHANGELOG.md | 5 +++++ src/data_value.rs | 2 +- src/ua/data_types/data_value.rs | 15 ++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8468acb..7ff419b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Add methods `ua::DataValue::with_source_timestamp()`, `ua::DataValue::with_server_timestamp()`, `ua::DataValue::with_source_picoseconds()`, `ua::DataValue::with_server_picoseconds()`. +## Changed + +- Rename methods `ua::DataValue::status_code()` to `status()`, `ua::DataValue::with_status_code()` + to `with_status()`. Deprecate the former methods. + ## [0.7.0] - 2024-12-13 ### Added diff --git a/src/data_value.rs b/src/data_value.rs index 8d19368..be0073f 100644 --- a/src/data_value.rs +++ b/src/data_value.rs @@ -14,7 +14,7 @@ impl DataValue { pub(crate) fn new(data_value: &ua::DataValue) -> Result { // Verify that data value is valid before accessing value. The OPC UA specification requires // us to do so. The status code may be omitted, in which case it is treated as valid data. - Error::verify_good(&data_value.status_code().unwrap_or(ua::StatusCode::GOOD))?; + Error::verify_good(&data_value.status().unwrap_or(ua::StatusCode::GOOD))?; // When the status code indicates a good data value, the value is expected to be set. let value = data_value diff --git a/src/ua/data_types/data_value.rs b/src/ua/data_types/data_value.rs index b2e6bb3..b8f393f 100644 --- a/src/ua/data_types/data_value.rs +++ b/src/ua/data_types/data_value.rs @@ -58,11 +58,10 @@ impl DataValue { self } + #[deprecated = "use Self::with_status() instead"] #[must_use] - pub fn with_status_code(mut self, status_code: &ua::StatusCode) -> Self { - status_code.clone_into_raw(&mut self.0.status); - self.0.set_hasStatus(true); - self + pub fn with_status_code(self, status_code: &ua::StatusCode) -> Self { + self.with_status(status_code) } /// Gets value. @@ -105,12 +104,18 @@ impl DataValue { } #[must_use] - pub fn status_code(&self) -> Option { + pub fn status(&self) -> Option { self.0 .hasStatus() .then(|| ua::StatusCode::new(self.0.status)) } + #[deprecated = "use Self::status() instead"] + #[must_use] + pub fn status_code(&self) -> Option { + self.status() + } + pub(crate) fn to_generic(&self) -> Result> { crate::DataValue::new(self) }