Browse
s.browse(node_id, filter) — Lists the direct child nodes (first level) of the specified node.
- For pagination of large nodes, please use BrowseWithPaging + BrowseNext.
- For path-based batch parsing, please use TranslateBrowsePaths.
Signature
pub fn Session::browse(&self, node_id: &str, filter: NodeClass)
-> Result<Vec<Reference>, OpcUaError>;
pub fn Session::browse_many(&self, node_ids: &[&str], filter: NodeClass)
-> Result<Vec<Vec<Reference>>, OpcUaError>;
"Reference" Field
pub struct Reference {
pub node_id: String,
pub browse_name: String, // Includes a prefix NamespaceIndex , such as "2:Temperature"
pub display_name: String,
pub node_class: NodeClass,
}
Example
use darra_opcua::NodeClass;
// List all child nodes Boiler1 under this node
let children = s.browse("ns=2;s=Boiler1", NodeClass::Unspecified)?;
for c in &children {
println!(" {:?} {} -> {}", c.node_class, c.browse_name, c.node_id);
}
// Show only Variable types
let vars = s.browse("ns=2;s=Boiler1", NodeClass::Variable)?;
// View Only Method
let methods = s.browse("ns=2;s=Calculator", NodeClass::Method)?;
Batch Browse (browse_many)
If you want to view multiple nodes at the same time (for example, when expanding the tree for the first GUI time), do it in one browse_many go RPC:
let roots = ["i=85", "i=86"]; // Objects + Types
let results = s.browse_many(&roots, NodeClass::Unspecified)?;
for (root, children) in roots.iter().zip(results.iter()) {
println!("{}:", root);
for c in children {
println!(" {}", c.browse_name);
}
}
If a node fails to be browsed (NodeId error), the corresponding slot returns null Vec, Does not return Err.
NodeClass filter
pub enum NodeClass {
Unspecified = 0,
Object = 1,
Variable = 2,
Method = 4,
ObjectType = 8,
VariableType = 16,
ReferenceType = 32,
DataType = 64,
View = 128,
}
| Value | Includes |
|---|---|
| Unspecified | All |
| Object | Object Only |
| Variable | Variable Only |
| Method | Method Only |
Currently, SDK
only a single NodeClass
filter is supported (bitwise OR combinations are not supported); if you need multiple classes, please Unspecified
retrieve all of them and filter them on the client side.
Error
OpcUaError Bring:
BAD_NODE_ID_UNKNOWN— Node does not existBAD_COMMUNICATION_ERROR— Network OutageINVALID_ARGUMENT— node_id contains NUL
A transport failure results in a return Err; a failure to parse a single child node does not result in a return Err.
Pagination for Large Nodes (ContinuationPoint)
The number of references browse returned in a single request is determined by the server; if the number exceeds the server's limit for a single response, the results will be truncated. When truncated, browse only the first page is returned.
To view the entire content, use BrowseWithPaging + BrowseNext:
let mut page = s.browse_with_paging("ns=2;s=BigFolder", NodeClass::Unspecified)?;
let mut all_refs = page.references.clone();
while let Some(cp) = page.continuation_point.take() {
if cp.is_empty() { break; }
page = s.browse_next(&cp, false)?;
all_refs.extend(page.references.iter().cloned());
}
Or in a single line:
let all = s.browse_all("ns=2;s=BigFolder", NodeClass::Unspecified, 100)?;
Reference → Node Conversion
for r in s.browse("ns=2;s=Boiler1", NodeClass::Variable)? {
let node = r.to_node(&s); // Operational Node
let dv = node.value()?;
println!("{} = {:?}", r.display_name, dv.variant());
}
Performance
- Single request Browse: One round trip over the network + server-side processing; the time taken varies depending on the network and server, so test it in your actual environment.
browse_manyBatch: Total time ≈ Single operation (saves N-1 round trips)- When the number of child nodes exceeds the server's per-response limit the result is paginated; use
browse_all/browse_nextto walk it
browse_filtered — Direction + Reference Type Filtering
browse_filtered It has four browse additional parameters— + BrowseDirection reference_type_id + include_subtypes + —compared API result_mask to (Part 4 §5.8.2.2).
Currently, these four parameters do not take effect., See "Implementation Notes" below.
pub fn browse_filtered(
&self,
node_id: &str,
node_class_filter: NodeClass,
direction: BrowseDirection,
reference_type_id: Option<&str>,
include_subtypes: bool,
result_mask: u32,
) -> Result<Vec<Reference>, OpcUaError>
Related Structures:
pub enum BrowseDirection {
Forward = 0, // Forward-only, parent→child
Inverse = 1, // Reverse only: child → parent
Both = 2, // Returns results in both directions
}
Example
use darra_opcua::BrowseDirection;
// 1) Forward propagation + HierarchicalReferences (i=33) —— The current implementation filters NodeClass only by
let children = ua.browse_filtered("ns=2;s=Boiler1",
NodeClass::Unspecified, BrowseDirection::Forward,
Some("i=33"), true, 0x3F)?;
// 2) Send in reverse — If you need to "keep only the parent node," please filter the data yourself on the client side.
let parents = ua.browse_filtered("ns=2;s=Tank.Level",
NodeClass::Unspecified, BrowseDirection::Inverse, None, true, 0x3F)?;
for p in &parents {
println!("父: {}", p.browse_name);
}
// 3) Bidirectional
let all = ua.browse_filtered("ns=2;s=Robot.Joint1",
NodeClass::Unspecified, BrowseDirection::Both, None, true, 0x3F)?;
Implementation Notes
The current implementation always falls back to browse(node_id, node_class_filter); only NodeClass filtering takes effect:
direction/reference_type_id/include_subtypes/ The fourresult_maskparameters are simply discarded in the implementation (let _ = (direction, reference_type_id, include_subtypes, result_mask);), It neither takes effect nor generates a warning..DarraUa_Session_BrowseWithFilterNot currently exported (The only entry points for browsing the underlying content areDarraUa_Session_BrowseNode/DarraUa_Session_BrowseNodes/DarraUa_Session_BrowseNext), Calling it by this name will fail.
After the underlying layer exports this entry point, it can be switched to a native call; the public interface remains unchanged API.
The direction / reference_type_id parameter in the example aboveThis does not affect the return results at this time..
If you need to filter by direction or reference type, please filter the returned data yourself Reference on the client side.