Skip to main content

BrowseNext

When Browse / BrowseWithPaging If the number of child nodes returned exceeds the server's single-page limit, the server will return a non-empty ContinuationPoint (paging token). Use browse_next to retrieve the next page.

Prerequisite Reading

Signature​

pub fn Session::browse_next(
&self,
continuation_point: &[u8],
release: bool,
) -> Result<BrowsePage, OpcUaError>;
ParametersNote
continuation_pointLast Browse/ BrowseNext returned continuation token
releasetrue = Abort further paging; the server releases resources (no references are returned)

BrowsePage Field​

pub struct BrowsePage {
pub references: Vec<Reference>,
/// "Some" (not empty) indicates that there are more pages; use "Continue" to browse browse_next further.
/// "None / Some" (blank) indicates that there are no more pages.
pub continuation_point: Option<Vec<u8>>,
}

Complete Page-Turning Example​

use darra_opcua::NodeClass;

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());
}

println!("Total {} children", all_refs.len());

Proactive Release (Saves Server Resources)​

The server ContinuationPoint maintains a status for each one, which consumes resources. If you don't want to continue browsing partway through, call release=true the explicit release function:

s.browse_next(&cp, true)?;

Otherwise, these ContinuationPoint will continue to consume server resources until the server reclaims them on its own; the timing of reclamation is determined by the server’s implementation (which varies by server), so do not rely on it—if you need to ensure they are released, do so explicitly release=true.

Session::browse_all Internal loop browse_next until ContinuationPoint empty, Finally, automatically release any remaining resources:

pub fn browse_all(&self, node_id: &str, filter: NodeClass, max_pages: usize)
-> Result<Vec<Reference>, OpcUaError>;
  • max_pages — Safety limit to prevent the server from continuously returning errors, which could CP lead to an infinite loop
  • max_pages Once is reached, actively CP release the current.
let all = s.browse_all("ns=2;s=BigFolder", NodeClass::Variable, 50)?;
println!("{} variables under BigFolder", all.len());

Note​

  • ContinuationPoint is an opaque byte array, Do not modify / parse
  • Each one can only ContinuationPoint be used once.
  • The server imposes a limit on the number ContinuationPoint of sessions per user; this limit varies by server. The server also determines how to handle situations where the limit is exceeded—release sessions as soon as they are no longer needed; do not hold onto them.

Next Step​