Skip to main content

PvaServer

Struct PvaServer 

Source
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

Source

pub fn builder() -> PvaServerBuilder

Create a builder for configuring a PvaServer.

Source

pub fn store(&self) -> &Arc<SimplePvStore>

Get a reference to the underlying store for runtime get/put.

Source

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.

Source

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.

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?;
Source

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

Source

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

pub async fn run(self) -> Result<(), Box<dyn Error>>

Start the PVA server (UDP search + TCP handler + beacon + scan tasks).

This blocks until the server is shut down or an error occurs.

Source§

impl PvaServer

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more