Skip to main content

MonitorBuilder

Struct MonitorBuilder 

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

MonitorBuilder provides a builder pattern for creating monitors with advanced configuration

This follows the PVXS MonitorBuilder pattern, allowing configuration of event masks and callbacks before creating the subscription.

§Example

use pvxs_sys::Context;

let mut ctx = Context::from_env()?;
let monitor = ctx.monitor_builder("MY:PV")?
    .connect_exception(true)
    .disconnect_exception(true)
    .exec()?;

Implementations§

Source§

impl MonitorBuilder

Source

pub fn connect_exception(self, enable: bool) -> Self

Enable or disable connection exceptions in the monitor queue

This is the user-friendly API - think in terms of what you want to enable.

§Arguments
  • enable - true to throw connection exceptions, false to suppress them (default: false)
§Example
let monitor = ctx.monitor_builder("MY:PV")?
    .connect_exception(true) // Throw connection exceptions
    .exec()?;
Source

pub fn disconnect_exception(self, enable: bool) -> Self

Enable or disable disconnection exceptions in the monitor queue

This is the user-friendly API - think in terms of what you want to enable.

§Arguments
  • enable - true to throw disconnection exceptions, false to suppress them (default: true)
§Example
let monitor = ctx.monitor_builder("MY:PV")?
    .disconnect_exception(true) // Throw disconnection exceptions
    .exec()?;
Source

pub fn event(self, callback: extern "C" fn()) -> Self

Set an event callback function that will be invoked when the subscription queue becomes not-empty

This follows the PVXS pattern where the callback is invoked when events are available, not for each individual event. The callback should then use pop() to retrieve events.

§Arguments
  • callback - Function to be called when events are available
§Example

extern "C" fn my_callback() {
    println!("Events available in subscription queue!");
}

let monitor = ctx.monitor_builder("MY:PV")?
    .event(my_callback)
    .exec()?;
Source

pub fn exec(self) -> Result<Monitor>

Execute and create the monitor subscription

Creates the actual monitor subscription with the configured settings.

§Returns

A Monitor instance ready for use.

§Example
let monitor = ctx.monitor_builder("MY:PV")?
    .connect_exception(true)
    .exec()?;
Source

pub fn exec_with_callback(self, callback_id: u64) -> Result<Monitor>

Execute with an event callback (for future implementation)

This is a placeholder for future callback support. Currently behaves the same as exec().

§Arguments
  • callback_id - Identifier for the callback (currently unused)
§Example
let monitor = ctx.monitor_builder("MY:PV")?
    .exec_with_callback(123)?;

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.