Skip to content

feat: implemented TranslateBrowsePathsToNodeIds service - #309

Open
nmammeri wants to merge 6 commits into
HMIProject:mainfrom
nmammeri:feat/add-translate-browse-path-service
Open

nmammeri wants to merge 6 commits into
HMIProject:mainfrom
nmammeri:feat/add-translate-browse-path-service

Conversation

@nmammeri

Copy link
Copy Markdown

No description provided.

@uklotzde

Copy link
Copy Markdown
Collaborator

Thanks for contributing!

Sorry for letting you wait. Holidays and higher priority product work delayed the review of your PR. We'll take a look.

@uklotzde uklotzde left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only some minor remarks from my side.

impl TranslateBrowsePathsToNodeIdsResponse {
#[must_use]
pub fn results(&self) -> Option<ua::Array<ua::BrowsePathResult>> {
ua::Array::from_raw_parts(self.0.resultsSize, self.0.results)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the TODO comments about returning "non-owned" results from similar methods. Just for consistency.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the TODO, same as the other responses.

Comment thread src/async_client.rs
/// # Errors
/// This fails only when the entire request fails. When a path does not exist or cannot be
/// translated, an inner `Err` is returned.
pub async fn translate_browse_path(

@uklotzde uklotzde Jan 12, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a convenience method for very simple use cases.

We should strive to reduce the amount of redundant code by calling self.translate_many_browse_paths(). Even if it has a minor performance overhead.

See also: read_attributes()/read_many_attributes()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, it now calls translate_many_browse_paths() like read_attributes() does.

Comment thread src/async_client.rs Outdated
return Err(Error::internal("unexpected number of browse path results"));
}

let targets: Vec<_> = results.iter().map(to_browse_path_result).collect();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the turbofish variant here. See also: #312

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to .collect::<Vec<_>>()

Comment thread examples/async_translate_browse_path.rs Outdated
}
}

// translate many browse paths

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use sentence-style line comments for consistency and readability. Starting with a capital letter and ending with a period. Even if the comment is not a complete sentence.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed both comments

@uklotzde

Copy link
Copy Markdown
Collaborator

We also need a changelog entry.

@uklotzde uklotzde added this to the v0.11.0 milestone Mar 28, 2026
@uklotzde uklotzde modified the milestones: v0.11.0, v0.11.1 Jul 13, 2026
@nmammeri
nmammeri force-pushed the feat/add-translate-browse-path-service branch from 1176032 to 5406564 Compare October 5, 2026 22:36
- Add TODO about returning non-owned results, consistent with other responses.
- Implement translate_browse_path() via translate_many_browse_paths().
- Use turbofish with collect().
- Use sentence-style line comments in example.
- Stop checking hard-coded node IDs in example, they change on the demo server.
- Add changelog entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nmammeri

nmammeri commented Oct 5, 2026

Copy link
Copy Markdown
Author

I rebased onto main and also changed the example to stop checking hard-coded node IDs. The demo server changed the ID for CoffeeBeanLevel, so the example now just prints the IDs it gets back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants