pub enum ParameterValue {
NotSet,
Bool(bool),
Integer(i64),
Double(f64),
String(String<MAX_STRING_VALUE_LEN>),
ByteArray(Vec<u8, MAX_BYTE_ARRAY_LEN>),
BoolArray(Vec<bool, MAX_ARRAY_LEN>),
IntegerArray(Vec<i64, MAX_ARRAY_LEN>),
DoubleArray(Vec<f64, MAX_ARRAY_LEN>),
StringArray(Vec<String<MAX_STRING_VALUE_LEN>, MAX_ARRAY_LEN>),
}Expand description
Parameter value container
Holds a parameter value of any supported type. Note: This enum is intentionally large to support all parameter types without heap allocation in embedded systems.
Variants§
NotSet
Value not set
Bool(bool)
Boolean value
Integer(i64)
64-bit signed integer value
Double(f64)
64-bit floating point value
String(String<MAX_STRING_VALUE_LEN>)
String value
ByteArray(Vec<u8, MAX_BYTE_ARRAY_LEN>)
Byte array value
BoolArray(Vec<bool, MAX_ARRAY_LEN>)
Boolean array value
IntegerArray(Vec<i64, MAX_ARRAY_LEN>)
Integer array value
DoubleArray(Vec<f64, MAX_ARRAY_LEN>)
Double array value
StringArray(Vec<String<MAX_STRING_VALUE_LEN>, MAX_ARRAY_LEN>)
String array value (array of fixed-size strings)
Implementations§
Source§impl ParameterValue
impl ParameterValue
Sourcepub fn assign_from(&mut self, src: &ParameterValue)
pub fn assign_from(&mut self, src: &ParameterValue)
Issue 2070 — copy src into self in place.
*self = src.clone() builds the clone on the stack first, and a
ParameterValue is as large as its largest variant (~8 KiB at the
default capacities). This switches self to src’s variant with an
empty payload and copies the payload element by element, so no
full-size temporary exists. Both values share the capacities, so every
copy fits.
Sourcepub fn param_type(&self) -> ParameterType
pub fn param_type(&self) -> ParameterType
Get the parameter type for this value
Sourcepub fn as_integer(&self) -> Option<i64>
pub fn as_integer(&self) -> Option<i64>
Try to get the value as an integer
Sourcepub fn as_byte_array(&self) -> Option<&[u8]>
pub fn as_byte_array(&self) -> Option<&[u8]>
Try to get the value as a byte array slice
Sourcepub fn as_bool_array(&self) -> Option<&[bool]>
pub fn as_bool_array(&self) -> Option<&[bool]>
Try to get the value as a bool array slice
Sourcepub fn as_integer_array(&self) -> Option<&[i64]>
pub fn as_integer_array(&self) -> Option<&[i64]>
Try to get the value as an integer array slice
Sourcepub fn as_double_array(&self) -> Option<&[f64]>
pub fn as_double_array(&self) -> Option<&[f64]>
Try to get the value as a double array slice
Sourcepub fn from_integer(value: i64) -> Self
pub fn from_integer(value: i64) -> Self
Create an integer value
Sourcepub fn from_double(value: f64) -> Self
pub fn from_double(value: f64) -> Self
Create a double value
Sourcepub fn from_string(value: &str) -> Option<Self>
pub fn from_string(value: &str) -> Option<Self>
Create a string value from a str slice
Sourcepub fn from_bool_array(values: &[bool]) -> Option<Self>
pub fn from_bool_array(values: &[bool]) -> Option<Self>
Create a bool-array value from a slice.
phase-426 W4 — None when the slice is longer than MAX_ARRAY_LEN,
the same fallible shape from_string has for the
same reason: the value lives in a heapless::Vec inside the server’s
fixed slot and there is no allocator to grow it.
These three exist so a caller outside nros-params can build an array
value without naming heapless or the capacity constant. The C++ FFI
shim is such a caller: nros_cpp_node_declare_param_*_array forwards
nros::ComponentNode’s std::vector<T> facade into the executor’s
store, and the capacity belongs where the storage is.
Sourcepub fn from_integer_array(values: &[i64]) -> Option<Self>
pub fn from_integer_array(values: &[i64]) -> Option<Self>
Create an integer-array value from a slice. See
from_bool_array.
Sourcepub fn from_double_array(values: &[f64]) -> Option<Self>
pub fn from_double_array(values: &[f64]) -> Option<Self>
Create a double-array value from a slice. See
from_bool_array.
Sourcepub fn from_byte_array(values: &[u8]) -> Option<Self>
pub fn from_byte_array(values: &[u8]) -> Option<Self>
Create a byte-array value from a slice; None past
MAX_BYTE_ARRAY_LEN. See from_bool_array.
Sourcepub fn assign_string(&mut self, value: &str) -> bool
pub fn assign_string(&mut self, value: &str) -> bool
Issue 2104 – set self to a string, IN PLACE: the from_*
constructors’ in-place twins, for a caller filling a slot it already
holds. from_string(v) returns an Option<Self>, and binding it puts
one or two ~8 KiB values on the caller’s stack; this writes into
self. false, with self left as an empty value of the variant, when
value exceeds MAX_STRING_VALUE_LEN.
Sourcepub fn assign_bool_array(&mut self, values: &[bool]) -> bool
pub fn assign_bool_array(&mut self, values: &[bool]) -> bool
Set self to a bool array in place; false past MAX_ARRAY_LEN.
See assign_string.
Sourcepub fn assign_integer_array(&mut self, values: &[i64]) -> bool
pub fn assign_integer_array(&mut self, values: &[i64]) -> bool
Set self to an integer array in place; false past
MAX_ARRAY_LEN. See assign_string.
Sourcepub fn assign_double_array(&mut self, values: &[f64]) -> bool
pub fn assign_double_array(&mut self, values: &[f64]) -> bool
Set self to a double array in place; false past
MAX_ARRAY_LEN. See assign_string.
Sourcepub fn assign_byte_array(&mut self, values: &[u8]) -> bool
pub fn assign_byte_array(&mut self, values: &[u8]) -> bool
Set self to a byte array in place; false past
MAX_BYTE_ARRAY_LEN. See assign_string.
Trait Implementations§
Source§impl Clone for ParameterValue
impl Clone for ParameterValue
Source§fn clone(&self) -> ParameterValue
fn clone(&self) -> ParameterValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more