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 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 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 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 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 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.