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.

Read results contain semantic values: an OPC DA VT_BSTR is returned with its exact contents, without display quote framing.

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.
CompatibilityReport
Full compatibility report for one connected gateway.
FeatureCompatibility
Result for one feature comparison.
GatewayInfo
Gateway-wide protocol information returned without contacting an OPC server.
IndexedSearchMatch
One selectable result from the persistent namespace index.
IndexedSearchProgress
Progress reported for a running persistent namespace inventory.
ProtocolFeatureSupport
One feature and the versions supported by a gateway.
ProtocolProfile
A component’s advertised protocol profile.
ProtocolVersionRange
Inclusive protocol version range supported by one component.
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 semantic 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.
CompatibilityEvidence
Evidence status for an otherwise protocol-compatible pairing.
CompatibilityFeature
A protocol surface whose versions are negotiated independently.
CompatibilitySource
Where a gateway compatibility profile came from.
CompatibilityStatus
Overall result of comparing a client and gateway profile.
Error
Errors that can occur while talking to an opcda-bridge gateway.
FeatureCompatibilityStatus
Result status for one protocol feature.
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§

current_client_profile
The current reusable client’s protocol profile.
evaluate_compatibility
Compare one client profile against one gateway profile.
legacy_gateway_profile
Convert legacy per-server capabilities into a gateway profile.
parse_value
Parse a raw string into bool, integer, float, or string form.
unknown_compatibility_report
Build an unknown report when an old gateway cannot answer either handshake.

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.