pub trait ParameterVariant: Clone {
// Required methods
fn to_parameter_value(&self) -> ParameterValue;
fn from_parameter_value(value: &ParameterValue) -> Option<Self>;
fn parameter_type() -> ParameterType;
// Provided method
fn try_to_parameter_value(&self) -> Result<ParameterValue, CapacityExceeded> { ... }
}Expand description
Trait for types that can be used as typed parameters
This trait provides conversions between Rust types and ParameterValue, enabling type-safe parameter access.
Required Methods§
Sourcefn to_parameter_value(&self) -> ParameterValue
fn to_parameter_value(&self) -> ParameterValue
Convert this type to a ParameterValue
Sourcefn from_parameter_value(value: &ParameterValue) -> Option<Self>
fn from_parameter_value(value: &ParameterValue) -> Option<Self>
Try to extract this type from a ParameterValue
Sourcefn parameter_type() -> ParameterType
fn parameter_type() -> ParameterType
Get the expected parameter type
Provided Methods§
Sourcefn try_to_parameter_value(&self) -> Result<ParameterValue, CapacityExceeded>
fn try_to_parameter_value(&self) -> Result<ParameterValue, CapacityExceeded>
Fallible conversion — Err(()) when self does not fit the
compile-time capacity (issue 0323).
Self::to_parameter_value cannot report that: the hosted std
impls used unwrap_or_default(), so an over-long String became
ParameterValue::NotSet (a TYPE change) and an oversized Vec
became an EMPTY array, both indistinguishable from a caller who
meant it. Callers at the declare/set boundary should prefer this.
Defaults to infallible for impls whose values cannot overflow (the
scalars); the std collection impls override it.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl ParameterVariant for String
Available on crate feature alloc only.
impl ParameterVariant for String
alloc only.fn to_parameter_value(&self) -> ParameterValue
fn try_to_parameter_value(&self) -> Result<ParameterValue, CapacityExceeded>
fn from_parameter_value(value: &ParameterValue) -> Option<String>
fn parameter_type() -> ParameterType
Source§impl ParameterVariant for String<nros_params::::types::{impl#9}::{constant#0}>
impl ParameterVariant for String<nros_params::::types::{impl#9}::{constant#0}>
fn to_parameter_value(&self) -> ParameterValue
fn from_parameter_value( value: &ParameterValue, ) -> Option<String<nros_params::::types::{impl#9}::{constant#0}>>
fn parameter_type() -> ParameterType
Source§impl ParameterVariant for Vec<String>
Available on crate feature alloc only.
impl ParameterVariant for Vec<String>
alloc only.fn to_parameter_value(&self) -> ParameterValue
fn try_to_parameter_value(&self) -> Result<ParameterValue, CapacityExceeded>
fn from_parameter_value(value: &ParameterValue) -> Option<Vec<String>>
fn parameter_type() -> ParameterType
Source§impl ParameterVariant for Vec<bool>
Available on crate feature alloc only.
impl ParameterVariant for Vec<bool>
alloc only.fn to_parameter_value(&self) -> ParameterValue
fn try_to_parameter_value(&self) -> Result<ParameterValue, CapacityExceeded>
fn from_parameter_value(value: &ParameterValue) -> Option<Vec<bool>>
fn parameter_type() -> ParameterType
Source§impl ParameterVariant for Vec<f64>
Available on crate feature alloc only.
impl ParameterVariant for Vec<f64>
alloc only.fn to_parameter_value(&self) -> ParameterValue
fn try_to_parameter_value(&self) -> Result<ParameterValue, CapacityExceeded>
fn from_parameter_value(value: &ParameterValue) -> Option<Vec<f64>>
fn parameter_type() -> ParameterType
Source§impl ParameterVariant for Vec<i64>
Available on crate feature alloc only.
impl ParameterVariant for Vec<i64>
alloc only.