pub struct ParameterBuilder<'a, 's, T: ParameterVariant> { /* private fields */ }Expand description
Builder for declaring a typed parameter
Implementations§
Source§impl<'a, 's, T: ParameterVariant> ParameterBuilder<'a, 's, T>
impl<'a, 's, T: ParameterVariant> ParameterBuilder<'a, 's, T>
Sourcepub fn new(
server: &'a mut ParameterServer<'s>,
node: NodeKey,
name: &'a str,
) -> Self
pub fn new( server: &'a mut ParameterServer<'s>, node: NodeKey, name: &'a str, ) -> Self
Create a new parameter builder
Sourcepub fn default(self, value: T) -> Self
pub fn default(self, value: T) -> Self
Set a default value for the parameter
The ONE default setter. rclrs also has default_from_iter(impl IntoIterator)
and default_string_array(&[&str]); neither exists here, so pass the array
value itself. An array is a heapless::Vec bounded by MAX_ARRAY_LEN (a
string array is Vec<String<MAX_STRING_VALUE_LEN>, MAX_ARRAY_LEN>, two
compile-time bounds), and an over-capacity value is refused by
ParameterVariant::try_to_parameter_value, never truncated. No allocator.
Sourcepub fn description(self, desc: &'a str) -> Self
pub fn description(self, desc: &'a str) -> Self
Set a human-readable description for the parameter
Sourcepub fn constraints(self, text: &'a str) -> Self
pub fn constraints(self, text: &'a str) -> Self
Set the free-text additional_constraints — rclrs’s
ParameterBuilder::constraints, and rclc’s fourth argument to
rclc_add_parameter_description (phase-417 W4.a).
Text longer than NROS_MAX_PARAM_CONSTRAINTS_LEN — whose default is
0, so an image pays for this field only when it asks for it — is
truncated at a character boundary and REPORTED once through
ParameterServer::take_truncated_descriptions, never dropped in
silence.
Sourcepub fn integer_range(
self,
min: i64,
max: i64,
step: i64,
) -> Result<Self, ParameterError>
pub fn integer_range( self, min: i64, max: i64, step: i64, ) -> Result<Self, ParameterError>
Set integer range constraints for the parameter
Sourcepub fn float_range(
self,
min: f64,
max: f64,
step: f64,
) -> Result<Self, ParameterError>
pub fn float_range( self, min: f64, max: f64, step: f64, ) -> Result<Self, ParameterError>
Set floating point range constraints for the parameter
Sourcepub fn range(self, range: RangeInclusive<T>) -> Result<Self, ParameterError>where
T: RangeConvertible,
pub fn range(self, range: RangeInclusive<T>) -> Result<Self, ParameterError>where
T: RangeConvertible,
Set range constraints using an inclusive range
This is a convenience method that works with RangeInclusive:
- For
i64parameters:range(0..=100)sets an integer range with step 1 - For
f64parameters:range(0.0..=1.0)sets a floating point range with step 0.0
For more control (e.g., custom step), use integer_range() or float_range().
Sourcepub fn read_only(self) -> Result<ReadOnlyParameter<'a, 's, T>, ParameterError>
pub fn read_only(self) -> Result<ReadOnlyParameter<'a, 's, T>, ParameterError>
Declare a read-only parameter
Read-only parameters cannot be changed after declaration. A default value must be provided.
Sourcepub fn mandatory(self) -> Result<MandatoryParameter<'a, 's, T>, ParameterError>
pub fn mandatory(self) -> Result<MandatoryParameter<'a, 's, T>, ParameterError>
Declare a mandatory parameter
If no default value is provided, it must be set externally before use.
Sourcepub fn optional(self) -> Result<OptionalParameter<'a, 's, T>, ParameterError>
pub fn optional(self) -> Result<OptionalParameter<'a, 's, T>, ParameterError>
Declare an optional parameter