nros_params/lib.rs
1//! Parameter server for nros
2//!
3//! This crate provides a ROS 2 compatible parameter server for embedded systems.
4//! Parameters live in storage the CALLER places and lends to the server
5//! ([`ParameterStorage`] / [`ParameterTable`]); [`MAX_PARAMETERS`] is only the
6//! default capacity of that storage.
7//!
8//! # Example
9//!
10//! ```
11//! use nros_params::{
12//! ParameterDescriptor, ParameterServer, ParameterStorage, ParameterType, ParameterValue,
13//! };
14//!
15//! // phase-382 W2' — storage is CALLER-OWNED: place it (a `static`, a struct
16//! // field, a local), then lend it. `ParameterStorage` defaults to
17//! // `MAX_PARAMETERS` slots; any length works, and the server's capacity is
18//! // whatever it is handed.
19//! let mut storage = ParameterStorage::<8>::new();
20//! let mut server = ParameterServer::new_in(storage.as_table());
21//!
22//! // Declare a simple parameter
23//! server.declare("max_speed", ParameterValue::Double(1.0));
24//!
25//! // Declare a parameter with constraints
26//! let desc = ParameterDescriptor::new("velocity", ParameterType::Double)
27//! .unwrap()
28//! .with_description("Maximum velocity in m/s")
29//! .with_float_range(0.0, 10.0, 0.1);
30//! server.declare_with_descriptor("velocity", ParameterValue::Double(5.0), Some(desc));
31//!
32//! // Get and set parameters
33//! assert_eq!(server.get_double("max_speed"), Some(1.0));
34//! server.set_double("max_speed", 2.0);
35//! ```
36//!
37//! # Features
38//!
39//! - `std` - Enable standard library support
40//! - `alloc` - Enable heap allocation
41
42#![no_std]
43
44#[cfg(feature = "std")]
45extern crate std;
46
47#[cfg(feature = "alloc")]
48extern crate alloc;
49
50pub(crate) mod config;
51// phase-359 W10 / issue 0080 — `persist` is GONE. It held the parameter
52// PERSISTENCE seam (`ParamStore`, `NullParamStore`, `ParamStoreError`,
53// `FileParamStore`), which 0080 ruled a non-goal in July: nano-ros does not
54// persist parameters on-device, and launch-baked defaults are the supported
55// model. Runtime get/set/describe — the `server` module — stay.
56pub mod server;
57pub mod typed;
58pub mod types;
59
60// Re-export main types
61pub use server::{LegacyParameterBuilder, ParameterServer, ParameterStorage, ParameterTable};
62pub use typed::{
63 MandatoryParameter, OptionalParameter, ParameterBuilder, ParameterError, RangeConvertible,
64 ReadOnlyParameter, UndeclaredParameters,
65};
66pub use types::{
67 FloatingPointRange, IntegerRange, MAX_ARRAY_LEN, MAX_BYTE_ARRAY_LEN, MAX_PARAM_NAME_LEN,
68 MAX_PARAMETERS, MAX_STRING_VALUE_LEN, Parameter, ParameterDescriptor, ParameterRange,
69 ParameterType, ParameterValue, ParameterVariant, SetParameterResult,
70};