pub struct ServeBuilder { /* private fields */ }Expand description
Builder for the PV-handle API. Wraps PvaServerBuilder and adds handle
binding at build() time.
Implementations§
Source§impl ServeBuilder
impl ServeBuilder
pub fn pvs(self, pvs: impl IntoIterator<Item = impl Into<AnyPv>>) -> Self
pub fn db_file(self, path: impl AsRef<str>) -> Self
pub fn db_string(self, content: &str) -> Self
pub fn source( self, label: impl Into<String>, order: i32, source: Arc<dyn Source>, ) -> Self
pub fn port(self, port: u16) -> Self
pub fn udp_port(self, port: u16) -> Self
pub fn listen_ip(self, ip: IpAddr) -> Self
pub fn advertise_ip(self, ip: IpAddr) -> Self
pub fn compute_alarms(self, enabled: bool) -> Self
pub fn beacon_period(self, secs: u64) -> Self
Sourcepub fn on_start<F>(self, hook: F) -> Self
pub fn on_start<F>(self, hook: F) -> Self
Register a startup hook. See PvaServerBuilder::on_start.
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 an event handler. See PvaServerBuilder::on_event.
Sourcepub fn event_sink(self, sink: Arc<dyn EventSink>) -> Self
pub fn event_sink(self, sink: Arc<dyn EventSink>) -> Self
Register an inline event sink. See PvaServerBuilder::event_sink.
Sourcepub async fn build(self) -> PvaServer
pub async fn build(self) -> PvaServer
Materialise records, links and scans from the handles, build the server, then bind every handle to the store.
Async because registering PUT validators post-build goes through
SimplePvStore::set_validator, which is async (an RwLock write);
there is no synchronous alternative and spvirit-server does not
depend on futures, so this awaits inline rather than blocking.
Sourcepub async fn start(self) -> Result<RunningServer, String>
pub async fn start(self) -> Result<RunningServer, String>
Build, run the on_start hooks to completion, then spawn the server;
returns a handle for typed access and shutdown.
Returns Err if a hook aborts startup, mirroring Python’s
start_background. This phase is awaited here rather than inside the
spawned task for two reasons: a hook that aborts must surface to the
caller instead of only reaching a tracing::error! they may have no
subscriber for, and hooks must have finished before start() returns
so RunningServer::pv(...) cannot read pre-hook values.
A failure after the hook phase (a bind error, say) still cannot be returned here — the server is serving by then — and is logged from the spawned task as before.