Skip to main content

ParameterDescriptor

Struct ParameterDescriptor 

Source
pub struct ParameterDescriptor {
    pub name: String<MAX_PARAM_NAME_LEN>,
    pub param_type: ParameterType,
    pub description: String<MAX_PARAM_DESCRIPTION_LEN>,
    pub additional_constraints: String<MAX_PARAM_CONSTRAINTS_LEN>,
    pub read_only: bool,
    pub dynamic_typing: bool,
    pub range: ParameterRange,
    /* private fields */
}
Expand description

Parameter descriptor containing metadata

Describes a parameter including its type, constraints, and documentation.

Fields§

§name: String<MAX_PARAM_NAME_LEN>

Parameter name

§param_type: ParameterType

Parameter type

§description: String<MAX_PARAM_DESCRIPTION_LEN>

Human-readable description.

phase-446 F2 – its own capacity, NROS_MAX_PARAM_DESCRIPTION_LEN. It used to share MAX_STRING_VALUE_LEN, which the contract derives to 0 for an image with no string parameter, so such an image could carry no description at all. Write it with Self::set_description, which truncates and records the truncation instead of dropping the text.

§additional_constraints: String<MAX_PARAM_CONSTRAINTS_LEN>

Free-text extra constraints — rcl_interfaces/msg/ParameterDescriptor’s additional_constraints, which ros2 param describe prints.

phase-417 W4.a — its own capacity, NROS_MAX_PARAM_CONSTRAINTS_LEN, default 0. Sharing the description’s knob was the first shape and the derived service buffer measured it wrong: the describe reply’s bound is a worst case over CAPACITY, not over use, so every image would have paid 256 bytes per parameter for a field it never sets — 2,048 bytes on the eight-parameter island, taking its reply past the 4,096 fallback. An image that wants constraint text states the knob. Write it with Self::set_additional_constraints, which truncates at a character boundary and records the truncation exactly as the description does, so a value that does not fit is reported rather than dropped in silence.

§read_only: bool

Whether the parameter is read-only

§dynamic_typing: bool

Whether the parameter type can change dynamically

§range: ParameterRange

Range constraints

Implementations§

Source§

impl ParameterDescriptor

Source

pub fn new(name: &str, param_type: ParameterType) -> Option<Self>

Create a new parameter descriptor

Source

pub fn with_description(self, desc: &str) -> Self

Set the description. A description longer than NROS_MAX_PARAM_DESCRIPTION_LEN is truncated at a character boundary and recorded (see Self::set_description).

Source

pub fn set_description(&mut self, desc: &str) -> bool

phase-446 F2 – set the description, truncating at a character boundary when it is longer than NROS_MAX_PARAM_DESCRIPTION_LEN. Returns whether it was truncated; the descriptor also remembers it, so the executor can report it once the parameter is declared.

Source

pub fn description_truncated(&self) -> bool

Whether the last description set was truncated and not yet reported.

Source

pub fn set_additional_constraints(&mut self, text: &str) -> bool

phase-417 W4.a — rclc’s additional_constraints, the fourth argument of rclc_add_parameter_description. Truncated and recorded like the description; returns whether anything was cut.

Source

pub fn with_additional_constraints(self, text: &str) -> Self

Source

pub fn with_read_only(self, read_only: bool) -> Self

Set read-only flag

Source

pub fn with_dynamic_typing(self, dynamic: bool) -> Self

Set dynamic typing flag

Source

pub fn with_integer_range(self, min: i64, max: i64, step: i64) -> Self

Set integer range constraints

Source

pub fn with_float_range(self, min: f64, max: f64, step: f64) -> Self

Set floating point range constraints

Source

pub fn validate_range(&self, value: &ParameterValue) -> bool

Check if a value satisfies the range constraints — min, max AND step.

Forwards to ParameterRange::contains, the single predicate.

Trait Implementations§

Source§

impl Clone for ParameterDescriptor

Source§

fn clone(&self) -> ParameterDescriptor

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParameterDescriptor

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.