Skip to main content

Value

Struct Value 

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

A PVAccess value container

Represents a structured data value returned from PVXS operations. Values have a hierarchical structure with named fields.

§Field Access

Values are accessed by field name. Common fields include:

  • "value": The primary data value
  • "alarm.severity": Alarm severity level
  • "alarm.status": Alarm status code
  • "timeStamp.secondsPastEpoch": Timestamp seconds

§Example

let value: Value = ctx.get("my:pv:name", 5.0).unwrap();

// Access different field types
let v = value.get_field_double("value").unwrap();
let severity = value.get_field_int32("alarm.severity").unwrap();

Implementations§

Source§

impl Value

Source

pub fn is_valid(&self) -> bool

Check if this value is valid

Returns false if the value is empty or uninitialized.

Source

pub fn get_field_double(&self, field_name: &str) -> Result<f64>

Get a field value as a double

§Errors

Returns an error if the field doesn’t exist or cannot be converted to a double.

Source

pub fn get_field_int32(&self, field_name: &str) -> Result<i32>

Get a field value as an i32

§Errors

Returns an error if the field doesn’t exist or cannot be converted to an i32.

Source

pub fn get_field_string(&self, field_name: &str) -> Result<String>

Get a field value as a String

§Errors

Returns an error if the field doesn’t exist or cannot be converted to a string.

Source

pub fn get_field_enum(&self, field_name: &str) -> Result<i16>

Get a field value as a enum

§Errors

Returns an error if the field doesn’t exist or cannot be converted to a enum.

Source

pub fn get_field_double_array(&self, field_name: &str) -> Result<Vec<f64>>

Get a field value as an array of doubles

Extracts a field containing an array of double-precision floating point values. Commonly used for waveform data, measurement arrays, or multi-point setpoints.

§Arguments
  • field_name - The field path (e.g., “value”, “waveform.data”)
§Errors

Returns an error if the field doesn’t exist or cannot be converted to an array of doubles.

§Example
let value = ctx.get("waveform:double:pv", 5.0).unwrap();
let array = value.get_field_double_array("value").unwrap();
println!("Double array length: {}", array.len());
for (i, val) in array.iter().enumerate().take(5) {
    println!("  [{}] = {}", i, val);
}
Source

pub fn get_field_int32_array(&self, field_name: &str) -> Result<Vec<i32>>

Get a field value as an array of int32

Extracts a field containing an array of 32-bit signed integers. Often used for status arrays, configuration parameters, or indexed data.

§Arguments
  • field_name - The field path (e.g., “value”, “status.codes”)
§Errors

Returns an error if the field doesn’t exist or cannot be converted to an array of int32.

§Example
let value = ctx.get("array:int32:pv", 5.0).unwrap();
let array = value.get_field_int32_array("value").unwrap();
println!("Int32 array length: {}", array.len());
for (i, val) in array.iter().enumerate().take(5) {
    println!("  [{}] = {}", i, val);
}
Source

pub fn get_field_string_array(&self, field_name: &str) -> Result<Vec<String>>

Get a field value as an array of strings

Extracts a field containing an array of string values. Commonly used for enum choices, device names, status messages, or text lists.

§Arguments
  • field_name - The field path (e.g., “value.choices”, “devices.names”)
§Errors

Returns an error if the field doesn’t exist or cannot be converted to an array of strings.

§Example
// Get enum choices for an NTEnum PV
let value = ctx.get("enum:pv", 5.0).unwrap();
let choices = value.get_field_string_array("value.choices").unwrap();
println!("Available choices:");
for (i, choice) in choices.iter().enumerate() {
    println!("  [{}] = '{}'", i, choice);
}

Trait Implementations§

Source§

impl Debug for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl !Send for Value

§

impl !Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

§

impl UnwindSafe for Value

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.