Expand description
Typed PV handles — the ergonomic front door to SimplePvStore.
A Pv<T> is created pending (it owns a record template plus attached
callbacks) and becomes bound to a store when passed to
PvaServer::serve(...). Handles are cheap clones; all clones observe and
drive the same record.
§Hello world
ⓘ
use spvirit_server::{AnyPv, Pv, PvaServer};
let temp = Pv::ai("SIM:TEMP", 22.5).units("C").prec(2);
let sp = Pv::ao("SIM:SETPOINT", 25.0)
.on_put(|_pv, v: f64| if v.is_finite() { Ok(()) } else { Err("NaN".into()) });
let server = PvaServer::serve([AnyPv::from(temp.clone()), AnyPv::from(sp)])
.start()
.await;
temp.set(23.1).await?;§Bulk creation
Handles are ordinary values, so a whole bank of PVs can be built with an
iterator and handed to serve as a Vec<AnyPv>:
ⓘ
use spvirit_server::{AnyPv, Pv, PvaServer};
let channels: Vec<Pv<f64>> = (0..8)
.map(|i| Pv::ai(format!("SIM:CH{i}"), 0.0).units("C"))
.collect();
let pvs: Vec<AnyPv> = channels.iter().cloned().map(AnyPv::from).collect();
let server = PvaServer::serve(pvs).start().await;
channels[0].set(21.3).await?;Structs§
- AnyPv
- Type-erased PV, as accepted by
PvaServer::serve/.pvs(...). - Pv
- Typed handle to a PV record. Cheap to clone; all clones share state.
- PvArray
- Handle to an array-backed record (
waveform/aai/aao). UnlikePv<T>this is untyped over the element kind — values areScalarArrayValue. Cheap to clone; all clones share state.
Enums§
- PvError
- Errors from typed PV handle operations.