aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2025-12-16 14:02:18 +0000
committerdiogo464 <[email protected]>2025-12-16 14:02:20 +0000
commit28c4116565bfe71ef7328f4a34458501ef3dc5b0 (patch)
treeca0cbefea550122aff5e325c2480e3a7ef421059
parenta16dbf1d55a6f5b28236eef566eea0f44524840c (diff)
fixed clippy warnings
-rw-r--r--src/command_policy.rs7
-rw-r--r--src/entity_switch.rs10
-rw-r--r--src/lib.rs2
3 files changed, 4 insertions, 15 deletions
diff --git a/src/command_policy.rs b/src/command_policy.rs
index 049d56a..e5859bb 100644
--- a/src/command_policy.rs
+++ b/src/command_policy.rs
@@ -64,16 +64,13 @@
64/// # async fn turn_on_motor() -> Result<(), ()> { Ok(()) } 64/// # async fn turn_on_motor() -> Result<(), ()> { Ok(()) }
65/// ``` 65/// ```
66#[derive(Debug, Clone, Copy, PartialEq, Eq)] 66#[derive(Debug, Clone, Copy, PartialEq, Eq)]
67#[derive(Default)]
67pub enum CommandPolicy { 68pub enum CommandPolicy {
68 /// Automatically publish the entity's state when a command is received. 69 /// Automatically publish the entity's state when a command is received.
70 #[default]
69 PublishState, 71 PublishState,
70 72
71 /// Do not automatically publish state. The application must manually update the state. 73 /// Do not automatically publish state. The application must manually update the state.
72 Manual, 74 Manual,
73} 75}
74 76
75impl Default for CommandPolicy {
76 fn default() -> Self {
77 Self::PublishState
78 }
79}
diff --git a/src/entity_switch.rs b/src/entity_switch.rs
index c1531eb..2b799a1 100644
--- a/src/entity_switch.rs
+++ b/src/entity_switch.rs
@@ -15,21 +15,13 @@ pub enum SwitchClass {
15/// 15///
16/// See [`CommandPolicy`] for details on how commands are handled. 16/// See [`CommandPolicy`] for details on how commands are handled.
17#[derive(Debug)] 17#[derive(Debug)]
18#[derive(Default)]
18pub struct SwitchConfig { 19pub struct SwitchConfig {
19 pub common: EntityCommonConfig, 20 pub common: EntityCommonConfig,
20 pub class: SwitchClass, 21 pub class: SwitchClass,
21 pub command_policy: CommandPolicy, 22 pub command_policy: CommandPolicy,
22} 23}
23 24
24impl Default for SwitchConfig {
25 fn default() -> Self {
26 Self {
27 common: Default::default(),
28 class: Default::default(),
29 command_policy: CommandPolicy::default(),
30 }
31 }
32}
33 25
34impl SwitchConfig { 26impl SwitchConfig {
35 pub(crate) fn populate(&self, config: &mut EntityConfig) { 27 pub(crate) fn populate(&self, config: &mut EntityConfig) {
diff --git a/src/lib.rs b/src/lib.rs
index 1b7c79a..edc60f2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1047,7 +1047,7 @@ pub async fn run<T: Transport>(device: &mut Device<'_>, transport: &mut T) -> Re
1047 .resize(device.publish_buffer.capacity(), 0) 1047 .resize(device.publish_buffer.capacity(), 0)
1048 .expect("resize to capacity should never fail"); 1048 .expect("resize to capacity should never fail");
1049 let n = 1049 let n =
1050 serde_json_core::to_slice(&tracker_state, &mut device.publish_buffer) 1050 serde_json_core::to_slice(&tracker_state, device.publish_buffer)
1051 .expect("publish buffer too small for tracker state payload"); 1051 .expect("publish buffer too small for tracker state payload");
1052 device.publish_buffer.truncate(n); 1052 device.publish_buffer.truncate(n);
1053 } 1053 }