aboutsummaryrefslogtreecommitdiff
path: root/src/entity_number.rs
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2025-12-14 14:49:02 +0000
committerdiogo464 <[email protected]>2025-12-14 14:49:02 +0000
commit993d2a9fd34ce08760933a013e638108827f6f70 (patch)
tree13897ca1a8eac0564fabc5b730bf9ae49a360fbb /src/entity_number.rs
parentab4a7c83e00314a2f5d2f455987ba530fd08bdd7 (diff)
Improve documentation and replace publish_on_command with CommandPolicy enum
- Enhanced crate-level documentation with comprehensive examples and feature list - Improved README with badges, better structure, and clearer examples - Added README.tpl template and generate-readme.sh script for cargo-readme - Documented run() and connect_and_run() functions with detailed behavior explanations - Replaced publish_on_command boolean with CommandPolicy enum (PublishState/Manual) - Added comprehensive documentation for CommandPolicy explaining both modes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Diffstat (limited to 'src/entity_number.rs')
-rw-r--r--src/entity_number.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/entity_number.rs b/src/entity_number.rs
index e2a89c1..1573000 100644
--- a/src/entity_number.rs
+++ b/src/entity_number.rs
@@ -1,5 +1,6 @@
1use crate::{ 1use crate::{
2 Entity, EntityCommonConfig, EntityConfig, NumberCommand, NumberState, NumberUnit, constants, 2 CommandPolicy, Entity, EntityCommonConfig, EntityConfig, NumberCommand, NumberState,
3 NumberUnit, constants,
3}; 4};
4 5
5#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] 6#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
@@ -61,6 +62,9 @@ pub enum NumberClass {
61 WindSpeed, 62 WindSpeed,
62} 63}
63 64
65/// Configuration for a number entity.
66///
67/// See [`CommandPolicy`] for details on how commands are handled.
64#[derive(Debug)] 68#[derive(Debug)]
65pub struct NumberConfig { 69pub struct NumberConfig {
66 pub common: EntityCommonConfig, 70 pub common: EntityCommonConfig,
@@ -70,7 +74,7 @@ pub struct NumberConfig {
70 pub step: Option<f32>, 74 pub step: Option<f32>,
71 pub mode: NumberMode, 75 pub mode: NumberMode,
72 pub class: NumberClass, 76 pub class: NumberClass,
73 pub publish_on_command: bool, 77 pub command_policy: CommandPolicy,
74} 78}
75 79
76impl Default for NumberConfig { 80impl Default for NumberConfig {
@@ -83,7 +87,7 @@ impl Default for NumberConfig {
83 step: None, 87 step: None,
84 mode: NumberMode::Auto, 88 mode: NumberMode::Auto,
85 class: NumberClass::Generic, 89 class: NumberClass::Generic,
86 publish_on_command: true, 90 command_policy: CommandPolicy::default(),
87 } 91 }
88 } 92 }
89} 93}