pub struct PvaServer { /* private fields */ }Expand description
High-level PVAccess server.
Built via PvaServer::builder() with typed record constructors,
.db_file() loading, .on_put() / .scan() callbacks, and a
simple .run() to start serving.
let server = PvaServer::builder()
.ai("SIM:TEMP", 22.5)
.ao("SIM:SP", 25.0)
.build();
// Read/write PVs from another task:
let store = server.store();
store.set_value("SIM:TEMP", ScalarValue::F64(23.1)).await;
server.run().await?;Implementations§
Source§impl PvaServer
impl PvaServer
Sourcepub fn builder() -> PvaServerBuilder
pub fn builder() -> PvaServerBuilder
Create a builder for configuring a PvaServer.
Sourcepub fn store(&self) -> &Arc<SimplePvStore> ⓘ
pub fn store(&self) -> &Arc<SimplePvStore> ⓘ
Get a reference to the underlying store for runtime get/put.
Sourcepub async fn pv<T: PvScalar>(&self, name: &str) -> Result<Pv<T>, PvError>
pub async fn pv<T: PvScalar>(&self, name: &str) -> Result<Pv<T>, PvError>
Mint a typed handle to any record in this server’s store — the
pre-run() counterpart of RunningServer::pv.
Sourcepub async fn array_pv(&self, name: &str) -> Result<PvArray, PvError>
pub async fn array_pv(&self, name: &str) -> Result<PvArray, PvError>
Mint an array handle to any record in this server’s store — the
pre-run() counterpart of RunningServer::array_pv.
Sourcepub fn add_source(
&mut self,
label: impl Into<String>,
order: i32,
source: Arc<dyn Source>,
)
pub fn add_source( &mut self, label: impl Into<String>, order: i32, source: Arc<dyn Source>, )
Register an additional Source after building the server.
This is useful when the source needs a reference to the store
(which is only available after .build()).
let server = PvaServer::builder().ai("X", 0.0).build();
let store = server.store().clone();
server.add_source("agg", 10, Arc::new(MyAggSource::new(store)));
server.run().await?;Sourcepub fn set_monitor_registry(&mut self, registry: Arc<MonitorRegistry>)
pub fn set_monitor_registry(&mut self, registry: Arc<MonitorRegistry>)
Pre-supply the MonitorRegistry that Self::run will use.
This lets external code (for example Python Source adapters)
hold onto the registry and publish monitor updates to subscribed
PVAccess clients from outside run().
Sourcepub fn monitor_registry(&mut self) -> Arc<MonitorRegistry> ⓘ
pub fn monitor_registry(&mut self) -> Arc<MonitorRegistry> ⓘ
Get a shared handle to the MonitorRegistry that will be used
when Self::run starts. Creates (and stores) a new registry
on first call so external code can register before run.
Source§impl PvaServer
impl PvaServer
Sourcepub fn serve(pvs: impl IntoIterator<Item = impl Into<AnyPv>>) -> ServeBuilder
pub fn serve(pvs: impl IntoIterator<Item = impl Into<AnyPv>>) -> ServeBuilder
Serve a collection of typed PV handles. Shorthand entry point for the
handle-based API; combine with .db_file(), .source(), etc.