pub struct PvaClient { /* private fields */ }Expand description
High-level PVAccess client.
Provides pvget, pvput, pvmonitor, and pvinfo methods that hide
the underlying protocol handshake.
let client = PvaClient::builder().build();
let val = client.pvget("MY:PV").await?;Implementations§
Source§impl PvaClient
impl PvaClient
Sourcepub fn builder() -> PvaClientBuilder
pub fn builder() -> PvaClientBuilder
Create a builder for configuring a PvaClient.
Sourcepub async fn pvget(&self, pv_name: &str) -> Result<PvGetResult, PvGetError>
pub async fn pvget(&self, pv_name: &str) -> Result<PvGetResult, PvGetError>
Fetch the current value of a PV.
Sourcepub async fn pvget_fields(
&self,
pv_name: &str,
fields: &[&str],
) -> Result<PvGetResult, PvGetError>
pub async fn pvget_fields( &self, pv_name: &str, fields: &[&str], ) -> Result<PvGetResult, PvGetError>
Fetch a PV with field filtering (equivalent to pvget -r "field(value,alarm)").
Sourcepub async fn pvput(
&self,
pv_name: &str,
value: impl Into<Value>,
) -> Result<(), PvGetError>
pub async fn pvput( &self, pv_name: &str, value: impl Into<Value>, ) -> Result<(), PvGetError>
Write a value to a PV.
Accepts anything convertible to serde_json::Value:
client.pvput("MY:PV", 42.0).await?;
client.pvput("MY:PV", "hello").await?;
client.pvput("MY:PV", serde_json::json!({"value": 1.5})).await?;Sourcepub async fn pvput_fields(
&self,
pv_name: &str,
value: impl Into<Value>,
fields: &[&str],
) -> Result<(), PvGetError>
pub async fn pvput_fields( &self, pv_name: &str, value: impl Into<Value>, fields: &[&str], ) -> Result<(), PvGetError>
Write to a PV with explicit field selection (dotted paths).
fields is forwarded as the PUT pvRequest. An empty slice is treated
as “all fields” (server returns full descriptor on INIT).
Sourcepub async fn open_put_channel(
&self,
pv_name: &str,
) -> Result<PvaChannel, PvGetError>
pub async fn open_put_channel( &self, pv_name: &str, ) -> Result<PvaChannel, PvGetError>
Open a persistent channel for high-rate PUT streaming.
Resolves the PV, establishes a channel, and completes the PUT INIT
handshake. The returned PvaChannel is ready for immediate
put calls.
Sourcepub async fn open_put_channel_fields(
&self,
pv_name: &str,
fields: &[&str],
) -> Result<PvaChannel, PvGetError>
pub async fn open_put_channel_fields( &self, pv_name: &str, fields: &[&str], ) -> Result<PvaChannel, PvGetError>
Open a persistent PUT channel with explicit field selection.
An empty fields slice requests all fields from the server.
Sourcepub async fn pvmonitor<F>(
&self,
pv_name: &str,
callback: F,
) -> Result<(), PvGetError>
pub async fn pvmonitor<F>( &self, pv_name: &str, callback: F, ) -> Result<(), PvGetError>
Subscribe to a PV and receive live updates via a callback.
The callback returns ControlFlow::Continue to keep listening or
ControlFlow::Break to stop the subscription.
use std::ops::ControlFlow;
client.pvmonitor("MY:PV", |value| {
println!("{value:?}");
ControlFlow::Continue(())
}).await?;Sourcepub async fn pvmonitor_fields<F>(
&self,
pv_name: &str,
fields: &[&str],
callback: F,
) -> Result<(), PvGetError>
pub async fn pvmonitor_fields<F>( &self, pv_name: &str, fields: &[&str], callback: F, ) -> Result<(), PvGetError>
Subscribe to a PV with explicit field selection (dotted paths).
fields is the MONITOR pvRequest. Each entry may be a top-level
field ("value") or a dotted nested path ("alarm.severity"). An
empty slice requests all fields.
Sourcepub async fn pvmonitor_with_options<F>(
&self,
pv_name: &str,
fields: &[&str],
options: MonitorOptions,
callback: F,
) -> Result<(), PvGetError>
pub async fn pvmonitor_with_options<F>( &self, pv_name: &str, fields: &[&str], options: MonitorOptions, callback: F, ) -> Result<(), PvGetError>
Subscribe to a PV with explicit field selection and monitor options.
See MonitorOptions — in particular, set pipeline to request
PVAccess monitor pipelining (flow-controlled delivery with client
ACKs). When pipelining is disabled this behaves identically to
pvmonitor_fields.
Sourcepub async fn pvinfo(&self, pv_name: &str) -> Result<StructureDesc, PvGetError>
pub async fn pvinfo(&self, pv_name: &str) -> Result<StructureDesc, PvGetError>
Retrieve the field/structure description (introspection) for a PV.
Sourcepub async fn pvinfo_full(
&self,
pv_name: &str,
) -> Result<(StructureDesc, SocketAddr), PvGetError>
pub async fn pvinfo_full( &self, pv_name: &str, ) -> Result<(StructureDesc, SocketAddr), PvGetError>
Retrieve introspection and server address for a PV.
Sourcepub async fn pvlist(
&self,
server_addr: SocketAddr,
) -> Result<Vec<String>, PvGetError>
pub async fn pvlist( &self, server_addr: SocketAddr, ) -> Result<Vec<String>, PvGetError>
List PV names served by a specific server (via __pvlist GET).
Sourcepub async fn pvlist_with_fallback(
&self,
server_addr: SocketAddr,
) -> Result<(Vec<String>, PvListSource), PvGetError>
pub async fn pvlist_with_fallback( &self, server_addr: SocketAddr, ) -> Result<(Vec<String>, PvListSource), PvGetError>
List PV names with automatic fallback through all strategies.
Tries: __pvlist → GET_FIELD (opt-in) → Server RPC → Server GET.