pub struct PvaServerBuilder { /* private fields */ }Expand description
Implementations§
Source§impl PvaServerBuilder
impl PvaServerBuilder
Sourcepub fn ai(self, name: impl Into<String>, initial: f64) -> Self
pub fn ai(self, name: impl Into<String>, initial: f64) -> Self
Add an ai (analog input, read-only) record.
Sourcepub fn ao(self, name: impl Into<String>, initial: f64) -> Self
pub fn ao(self, name: impl Into<String>, initial: f64) -> Self
Add an ao (analog output, writable) record.
Sourcepub fn bi(self, name: impl Into<String>, initial: bool) -> Self
pub fn bi(self, name: impl Into<String>, initial: bool) -> Self
Add a bi (binary input, read-only) record.
Sourcepub fn bo(self, name: impl Into<String>, initial: bool) -> Self
pub fn bo(self, name: impl Into<String>, initial: bool) -> Self
Add a bo (binary output, writable) record.
Sourcepub fn string_in(
self,
name: impl Into<String>,
initial: impl Into<String>,
) -> Self
pub fn string_in( self, name: impl Into<String>, initial: impl Into<String>, ) -> Self
Add a stringin (string input, read-only) record.
Sourcepub fn string_out(
self,
name: impl Into<String>,
initial: impl Into<String>,
) -> Self
pub fn string_out( self, name: impl Into<String>, initial: impl Into<String>, ) -> Self
Add a stringout (string output, writable) record.
Sourcepub fn waveform(self, name: impl Into<String>, data: ScalarArrayValue) -> Self
pub fn waveform(self, name: impl Into<String>, data: ScalarArrayValue) -> Self
Add a waveform record (array) with the given initial data.
Sourcepub fn aai(self, name: impl Into<String>, data: ScalarArrayValue) -> Self
pub fn aai(self, name: impl Into<String>, data: ScalarArrayValue) -> Self
Add an aai (analog array input, read-only) record.
Sourcepub fn aao(self, name: impl Into<String>, data: ScalarArrayValue) -> Self
pub fn aao(self, name: impl Into<String>, data: ScalarArrayValue) -> Self
Add an aao (analog array output, writable) record.
Sourcepub fn sub_array(
self,
name: impl Into<String>,
data: ScalarArrayValue,
indx: usize,
nelm: usize,
) -> Self
pub fn sub_array( self, name: impl Into<String>, data: ScalarArrayValue, indx: usize, nelm: usize, ) -> Self
Add a subarray record — a view into part of an array.
Sourcepub fn nt_table(
self,
name: impl Into<String>,
columns: Vec<(String, ScalarArrayValue)>,
) -> Self
pub fn nt_table( self, name: impl Into<String>, columns: Vec<(String, ScalarArrayValue)>, ) -> Self
Add an NTTable record.
Sourcepub fn nt_ndarray(
self,
name: impl Into<String>,
data: ScalarArrayValue,
dims: Vec<(i32, i32)>,
) -> Self
pub fn nt_ndarray( self, name: impl Into<String>, data: ScalarArrayValue, dims: Vec<(i32, i32)>, ) -> Self
Add an NTNDArray record.
Sourcepub fn mbbi(
self,
name: impl Into<String>,
choices: Vec<String>,
initial: i32,
) -> Self
pub fn mbbi( self, name: impl Into<String>, choices: Vec<String>, initial: i32, ) -> Self
Add an mbbi (multi-bit binary input, read-only) NTEnum record.
Sourcepub fn mbbo(
self,
name: impl Into<String>,
choices: Vec<String>,
initial: i32,
) -> Self
pub fn mbbo( self, name: impl Into<String>, choices: Vec<String>, initial: i32, ) -> Self
Add an mbbo (multi-bit binary output, writable) NTEnum record.
Sourcepub fn generic(
self,
name: impl Into<String>,
struct_id: impl Into<String>,
fields: Vec<(String, PvValue)>,
) -> Self
pub fn generic( self, name: impl Into<String>, struct_id: impl Into<String>, fields: Vec<(String, PvValue)>, ) -> Self
Add a generic structure record with a custom struct ID and fields.
Sourcepub fn db_file(self, path: impl AsRef<str>) -> Self
pub fn db_file(self, path: impl AsRef<str>) -> Self
Load records from an EPICS .db file.
A malformed .db is a startup configuration error, not a runtime
condition to log and shrug off: build() returns PvaServer, not a
Result, so there is no channel to report the failure through other
than refusing to start. Silently continuing with zero records from
this file would leave the server up and answering PVA requests while
serving none of the PVs its .db was supposed to define, which is
worse than failing loudly at startup. load_db’s error already names
the file and the line that failed to parse (see DbParseError’s
Display), so that detail reaches the panic message unmodified.
Sourcepub fn db_string(self, content: &str) -> Self
pub fn db_string(self, content: &str) -> Self
Parse records from an EPICS .db string.
See Self::db_file’s doc comment for why a parse failure panics
here rather than logging and continuing with zero records.
Sourcepub fn on_put<F>(self, name: impl Into<String>, callback: F) -> Self
pub fn on_put<F>(self, name: impl Into<String>, callback: F) -> Self
Register a callback invoked when a PUT is applied to the named PV.
Sourcepub fn scan<F>(
self,
name: impl Into<String>,
period: Duration,
callback: F,
) -> Self
pub fn scan<F>( self, name: impl Into<String>, period: Duration, callback: F, ) -> Self
Register a periodic scan callback that produces a new value for a PV.
Sourcepub fn on_start<F>(self, hook: F) -> Self
pub fn on_start<F>(self, hook: F) -> Self
Register a hook to run once at startup, before the server serves.
Hooks run in registration order, each to completion, before scan tasks spawn and before the listener accepts. A hook that panics aborts startup.
.on_start(|store| Box::pin(async move {
store.set_value("SETPOINT", ScalarValue::F64(22.5)).await;
}))Sourcepub fn on_event<F>(self, event: impl Into<String>, handler: F) -> Self
pub fn on_event<F>(self, event: impl Into<String>, handler: F) -> Self
Register a handler for a named event.
Handlers are deferred: post_event queues them and returns. They run
one at a time, in registration order, on the dispatcher.
.on_event("SHUTTER", |store, event| Box::pin(async move { /* ... */ }))Sourcepub fn event_sink(self, sink: Arc<dyn EventSink>) -> Self
pub fn event_sink(self, sink: Arc<dyn EventSink>) -> Self
Register an EventSink — an inline
consumer awaited by post_event before any handler is queued.
Sinks were previously reachable only through
PvaServer::events on an already-built server,
which leaves no seam for callers that only ever hold a builder (or a
ServeBuilder/RunningServer). Registration order across
builder-registered and post-build sinks is call order.
Sourcepub fn link<F>(
self,
output: impl Into<String>,
inputs: &[&str],
compute: F,
) -> Self
pub fn link<F>( self, output: impl Into<String>, inputs: &[&str], compute: F, ) -> Self
Link an output PV to one or more input PVs.
Whenever any input PV changes (via set_value, protocol PUT, or
another link), the compute callback is invoked with the current
values of all inputs (in order) and the result is written to
the output PV.
.link("CALC:SUM", &["INPUT:A", "INPUT:B"], |values| {
let a = values[0].as_f64().unwrap_or(0.0);
let b = values[1].as_f64().unwrap_or(0.0);
ScalarValue::F64(a + b)
})Sourcepub fn ioc<S: StoreSource + 'static>(self, ioc: Arc<S>) -> Self
pub fn ioc<S: StoreSource + 'static>(self, ioc: Arc<S>) -> Self
Register a processing engine as a second store.
Unlike PvaServerBuilder::source, this asserts the engine owns its
record names outright: build panics if any of them collide with a
record added to the builtin store (.ai(), .db_file() and
friends), or if a .scan, .link or on_put handler names one of
them. Those callbacks drive
the builtin store’s direct-write semantics and would be silently
inert against an engine record.
Generic rather than Arc<dyn StoreSource> so the names can be read
before the value is erased to Arc<dyn Source>.
§Panics
If called more than once.
Sourcepub fn advertise_ip(self, ip: IpAddr) -> Self
pub fn advertise_ip(self, ip: IpAddr) -> Self
Set the IP address to advertise in search responses.
Sourcepub fn compute_alarms(self, enabled: bool) -> Self
pub fn compute_alarms(self, enabled: bool) -> Self
Enable alarm computation from limits.
Sourcepub fn beacon_period(self, secs: u64) -> Self
pub fn beacon_period(self, secs: u64) -> Self
Set the beacon broadcast period in seconds (default 15).
Sourcepub fn conn_timeout(self, timeout: Duration) -> Self
pub fn conn_timeout(self, timeout: Duration) -> Self
Set the idle connection timeout (default ~18 hours).
Sourcepub fn pvlist_mode(self, mode: PvListMode) -> Self
pub fn pvlist_mode(self, mode: PvListMode) -> Self
Set the PV list mode (default PvListMode::List).
Sourcepub fn pvlist_max(self, max: usize) -> Self
pub fn pvlist_max(self, max: usize) -> Self
Set the maximum number of PV names in pvlist responses (default 1024).
Sourcepub fn pvlist_allow_pattern(self, pattern: Regex) -> Self
pub fn pvlist_allow_pattern(self, pattern: Regex) -> Self
Set a regex filter for PV names exposed by pvlist.