Skip to main content

Crate opcda_bridge

Crate opcda_bridge 

Source
Expand description

Reusable, presentation-free async client for the opcda-bridge gateway’s gRPC API.

This crate is the typed connect/read/write/browse/search/list-servers surface extracted from opcda-bridge-client’s commands.rs: no clap, no tabled, no serde_json/toml — just Client, the parameters its methods take, and the plain result types they return (BrowsePage, SearchEvent, SearchIndexResponse, TagValue, WriteResult, Value). opcda-bridge-client depends on this crate and adds only CLI parsing and table/JSON rendering on top of it; any other async Rust program that needs typed OPC DA reads/writes/browses without shelling out to the CLI binary and parsing its output can depend on this crate directly instead.

use opcda_bridge::{
    BrowsePageRequest, SearchIndexRequest, SearchMatchMode, SearchRequest,
};

let mut client = opcda_bridge::Client::connect("localhost:7600").await?;
let servers = client.list_servers().await?;
let root = client.browse(servers[0].clone(), 200).await?;
if let Some(token) = root.next_page_token.clone() {
    let request =
        BrowsePageRequest::next(servers[0].clone(), root.session_id.clone(), None, token, 200);
    let _next_page = client.browse_page(request).await?;
}
let mut search = client
    .search_stream(SearchRequest::new(
        servers[0].clone(),
        "Some",
        SearchMatchMode::Prefix,
    ))
    .await?;
while let Some(event) = search.message().await? {
    println!("{event:?}");
}
let indexed = client
    .search_index(SearchIndexRequest::new(
        servers[0].clone(),
        "Some PV",
        SearchMatchMode::Contains,
    ))
    .await?;
for found in indexed.matches {
    println!("{}: {}", found.display_name, found.item_id);
}
let values = client
    .read(servers[0].clone(), vec!["Some.Tag".into()])
    .await?;
client.close_browse_session(root.session_id).await?;

Structs§

BrowseBreadcrumb
One navigation step associated with a search match.
BrowseNode
One child returned by a browse page.
BrowsePage
One bounded page of immediate children and its continuation metadata.
BrowsePageRequest
Parameters for one browse-page request.
Capabilities
Gateway and namespace features reported for one OPC server.
Client
A connected client for an opcda-bridge gateway’s gRPC API.
IndexedSearchMatch
One selectable result from the persistent namespace index.
IndexedSearchProgress
Progress reported for a running persistent namespace inventory.
SearchCompleted
Terminal search metadata.
SearchIndexRequest
Parameters for one persistent-index query.
SearchIndexResponse
Ranked persistent-index matches plus snapshot readiness metadata.
SearchIndexStatus
Persistent namespace-index state and build metadata.
SearchMatch
A progressively emitted namespace-search result.
SearchProgress
Progress emitted while a namespace search is still running.
SearchRequest
Parameters for a bounded namespace search.
SearchStream
A cancellable stream of typed namespace-search events.
TagValue
A single tag’s value returned by crate::Client::read.
WriteResult
The result of a single crate::Client::write call.

Enums§

BrowseNodeKind
Whether a browse node is expandable, selectable as an OPC item, or both.
BrowseSource
Native or configured strategy that produced browse results.
Error
Errors that can occur while talking to an opcda-bridge gateway.
NamespaceOrganization
How the OPC server organizes its namespace.
SearchEvent
One event from the gateway’s search stream.
SearchIndexControlAction
Operator action applied to an active namespace-index build.
SearchIndexState
Readiness of a gateway-owned persistent namespace index.
SearchMatchMode
Match behavior for namespace search.
Value
A tag value to write, parsed from a raw string via parse_value.

Constants§

DEFAULT_BRIDGE_PORT
Default TCP port used by the gateway and clients.
DEFAULT_INDEX_SEARCH_MAX_RESULTS
Default maximum number of matches requested from the persistent index.
DEFAULT_PAGE_SIZE
Default number of children requested for one browse page.
DEFAULT_SEARCH_MAX_RESULTS
Default maximum number of matches requested by a search.

Functions§

parse_value
Parse a raw string into bool, integer, float, or string form.

Type Aliases§

Result
A Result alias using Error, mirroring the ergonomics of anyhow::Result (opcda_bridge::Result<T>) for a crate that intentionally does not depend on anyhow itself.