Skip to main content

ParameterVariant

Trait ParameterVariant 

Source
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§

Source

fn to_parameter_value(&self) -> ParameterValue

Convert this type to a ParameterValue

Source

fn from_parameter_value(value: &ParameterValue) -> Option<Self>

Try to extract this type from a ParameterValue

Source

fn parameter_type() -> ParameterType

Get the expected parameter type

Provided Methods§

Source

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.
Source§

impl ParameterVariant for String<nros_params::::types::{impl#9}::{constant#0}>

Source§

fn to_parameter_value(&self) -> ParameterValue

Source§

fn from_parameter_value( value: &ParameterValue, ) -> Option<String<nros_params::::types::{impl#9}::{constant#0}>>

Source§

fn parameter_type() -> ParameterType

Source§

impl ParameterVariant for Vec<String>

Available on crate feature alloc only.
Source§

impl ParameterVariant for Vec<bool>

Available on crate feature alloc only.
Source§

impl ParameterVariant for Vec<f64>

Available on crate feature alloc only.
Source§

impl ParameterVariant for Vec<i64>

Available on crate feature alloc only.
Source§

impl ParameterVariant for bool

Source§

impl ParameterVariant for f64

Source§

impl ParameterVariant for i64

Implementors§