Skip to main content

Server

Struct Server 

Source
pub struct Server { /* private fields */ }
Expand description

A PVXS server for hosting process variables with automatic alarm management

The Server provides managed PVs with automatic alarm handling, control limit validation, and value alarm checking. This is the recommended way to create EPICS servers in Rust.

§Features

  • Automatic alarm computation based on control limits and value alarms
  • Thread-safe PV management with internal worker thread
  • Support for multiple data types (double, int32, string, enum, arrays)
  • Isolated or environment-configured operation

§Example

use pvxs_sys::{Server, NTScalarMetadataBuilder, ControlMetadata};

let server = Server::start_from_env()?;

// Create a PV with control limits
let metadata = NTScalarMetadataBuilder::new()
    .control(ControlMetadata {
        limit_low: 0.0,
        limit_high: 100.0,
        min_step: 0.1,
    });

server.create_pv_double("test:pv", 50.0, metadata)?;
server.post_double("test:pv", 75.0)?;  // Validated and with alarms

server.stop_drop()?;

Implementations§

Source§

impl Server

Source

pub fn start_from_env() -> Result<Self>

Start a server using environment configuration

Creates and starts a server that reads EPICS network configuration from environment variables.

§Errors

Returns an error if the server cannot be created or started.

Source

pub fn start_isolated() -> Result<Self>

Start an isolated server for testing

Creates and starts a server with system-assigned ports, ideal for unit tests and parallel test execution.

§Errors

Returns an error if the server cannot be created or started.

Source

pub fn handle(&self) -> ServerHandle

Get a cloneable handle to this server

The handle can be used from other threads to interact with the server.

Source

pub fn tcp_port(&self) -> u16

Source

pub fn udp_port(&self) -> u16

Source

pub fn create_pv_double( &self, name: &str, initial: f64, metadata: NTScalarMetadataBuilder, ) -> Result<()>

Source

pub fn create_pv_double_array( &self, name: &str, initial: Vec<f64>, metadata: NTScalarMetadataBuilder, ) -> Result<()>

Source

pub fn create_pv_int32( &self, name: &str, initial: i32, metadata: NTScalarMetadataBuilder, ) -> Result<()>

Source

pub fn create_pv_int32_array( &self, name: &str, initial: Vec<i32>, metadata: NTScalarMetadataBuilder, ) -> Result<()>

Source

pub fn create_pv_string( &self, name: &str, initial: &str, metadata: NTScalarMetadataBuilder, ) -> Result<()>

Source

pub fn create_pv_string_array( &self, name: &str, initial: Vec<String>, metadata: NTScalarMetadataBuilder, ) -> Result<()>

Source

pub fn create_pv_enum( &self, name: &str, choices: Vec<&str>, selected_index: i16, metadata: NTEnumMetadataBuilder, ) -> Result<()>

Source

pub fn post_double(&self, name: &str, value: f64) -> Result<()>

Source

pub fn post_double_array(&self, name: &str, value: Vec<f64>) -> Result<()>

Source

pub fn post_int32(&self, name: &str, value: i32) -> Result<()>

Source

pub fn post_int32_array(&self, name: &str, value: Vec<i32>) -> Result<()>

Source

pub fn post_string(&self, name: &str, value: &str) -> Result<()>

Source

pub fn post_string_array(&self, name: &str, value: Vec<String>) -> Result<()>

Source

pub fn post_enum(&self, name: &str, value: i16) -> Result<()>

Source

pub fn remove_pv(&self, name: &str) -> Result<()>

Source

pub fn fetch_double(&self, name: &str) -> Result<FetchedDouble>

Source

pub fn fetch_int32(&self, name: &str) -> Result<FetchedInt32>

Source

pub fn fetch_string(&self, name: &str) -> Result<FetchedString>

Source

pub fn fetch_double_array(&self, name: &str) -> Result<FetchedDoubleArray>

Source

pub fn fetch_int32_array(&self, name: &str) -> Result<FetchedInt32Array>

Source

pub fn fetch_string_array(&self, name: &str) -> Result<FetchedStringArray>

Source

pub fn fetch_enum(&self, name: &str) -> Result<FetchedEnum>

Source

pub fn stop_drop(self) -> Result<()>

Indirectly calls inner stop through the manager thread, ensuring proper shutdown and resource cleanup Once Stop command is sent the worker thread will exit, however it will destroy the ServerImpl and the entire pvs hashmap so the all underlying C++ objects are freed correctly.

Call start_from_env or start_isolated again and create new PVs to start a new server instance if needed after stopping.

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, 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.