Skip to content

Commit

Permalink
Rename methods to be consistent with open62541 names
Browse files Browse the repository at this point in the history
  • Loading branch information
sgoll committed Dec 19, 2024
1 parent 7a21218 commit 22cf6c7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/data_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl<T: DataType> DataValue<T> {
pub(crate) fn new(data_value: &ua::DataValue) -> Result<Self> {
// 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
Expand Down
15 changes: 10 additions & 5 deletions src/ua/data_types/data_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -105,12 +104,18 @@ impl DataValue {
}

#[must_use]
pub fn status_code(&self) -> Option<ua::StatusCode> {
pub fn status(&self) -> Option<ua::StatusCode> {
self.0
.hasStatus()
.then(|| ua::StatusCode::new(self.0.status))
}

#[deprecated = "use Self::status() instead"]
#[must_use]
pub fn status_code(&self) -> Option<ua::StatusCode> {
self.status()
}

pub(crate) fn to_generic<T: DataType>(&self) -> Result<crate::DataValue<T>> {
crate::DataValue::new(self)
}
Expand Down

0 comments on commit 22cf6c7

Please # to comment.