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
impl Value
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Check if this value is valid
Returns false if the value is empty or uninitialized.
Sourcepub fn get_field_double(&self, field_name: &str) -> Result<f64>
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.
Sourcepub fn get_field_int32(&self, field_name: &str) -> Result<i32>
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.
Sourcepub fn get_field_string(&self, field_name: &str) -> Result<String>
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.
Sourcepub fn get_field_enum(&self, field_name: &str) -> Result<i16>
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.
Sourcepub fn get_field_double_array(&self, field_name: &str) -> Result<Vec<f64>>
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);
}Sourcepub fn get_field_int32_array(&self, field_name: &str) -> Result<Vec<i32>>
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);
}Sourcepub fn get_field_string_array(&self, field_name: &str) -> Result<Vec<String>>
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);
}