aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2025-12-09 22:58:31 +0000
committerdiogo464 <[email protected]>2025-12-09 22:58:31 +0000
commit4687daaf620e0d0951e4657d052eaa713d18fa71 (patch)
tree969d8f67a9af7e0b5b7488478cb329a1185923c2 /src/lib.rs
parent9aed552c491aaabc84e3141bc70e4d26c03efa85 (diff)
small visibility fixesv0.1.0
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 50c6308..234d0e9 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,6 +1,7 @@
1//! Home Assistant MQTT device library for embassy. 1//! Home Assistant MQTT device library for embassy.
2//! 2//!
3//! To create a device use the [`new`] function. 3//! To create a device use the [`new`] function.
4//!
4//! After the device is created you should create one or more entities using functions such as 5//! After the device is created you should create one or more entities using functions such as
5//! [`create_button`]/[`create_sensor`]/... 6//! [`create_button`]/[`create_sensor`]/...
6//! 7//!
@@ -30,8 +31,9 @@ use serde::Serialize;
30 31
31mod mqtt; 32mod mqtt;
32 33
33pub mod log; 34mod log;
34pub use log::Format; 35#[allow(unused)]
36use log::Format;
35 37
36pub mod constants; 38pub mod constants;
37 39
@@ -250,73 +252,79 @@ impl Default for DeviceResources {
250} 252}
251 253
252#[derive(Debug, Default)] 254#[derive(Debug, Default)]
253pub struct ButtonStorage { 255pub(crate) struct ButtonStorage {
254 pub timestamp: Option<embassy_time::Instant>, 256 pub timestamp: Option<embassy_time::Instant>,
255 pub consumed: bool, 257 pub consumed: bool,
256} 258}
257 259
258#[derive(Debug)] 260#[derive(Debug)]
259pub struct SwitchCommand { 261pub(crate) struct SwitchCommand {
260 pub value: BinaryState, 262 pub value: BinaryState,
263 #[allow(unused)]
261 pub timestamp: embassy_time::Instant, 264 pub timestamp: embassy_time::Instant,
262} 265}
263 266
264#[derive(Debug)] 267#[derive(Debug)]
265pub struct SwitchState { 268pub(crate) struct SwitchState {
266 pub value: BinaryState, 269 pub value: BinaryState,
270 #[allow(unused)]
267 pub timestamp: embassy_time::Instant, 271 pub timestamp: embassy_time::Instant,
268} 272}
269 273
270#[derive(Debug, Default)] 274#[derive(Debug, Default)]
271pub struct SwitchStorage { 275pub(crate) struct SwitchStorage {
272 pub state: Option<SwitchState>, 276 pub state: Option<SwitchState>,
273 pub command: Option<SwitchCommand>, 277 pub command: Option<SwitchCommand>,
274 pub publish_on_command: bool, 278 pub publish_on_command: bool,
275} 279}
276 280
277#[derive(Debug)] 281#[derive(Debug)]
278pub struct BinarySensorState { 282pub(crate) struct BinarySensorState {
279 pub value: BinaryState, 283 pub value: BinaryState,
284 #[allow(unused)]
280 pub timestamp: embassy_time::Instant, 285 pub timestamp: embassy_time::Instant,
281} 286}
282 287
283#[derive(Debug, Default)] 288#[derive(Debug, Default)]
284pub struct BinarySensorStorage { 289pub(crate) struct BinarySensorStorage {
285 pub state: Option<BinarySensorState>, 290 pub state: Option<BinarySensorState>,
286} 291}
287 292
288#[derive(Debug)] 293#[derive(Debug)]
289pub struct NumericSensorState { 294pub(crate) struct NumericSensorState {
290 pub value: f32, 295 pub value: f32,
296 #[allow(unused)]
291 pub timestamp: embassy_time::Instant, 297 pub timestamp: embassy_time::Instant,
292} 298}
293 299
294#[derive(Debug, Default)] 300#[derive(Debug, Default)]
295pub struct NumericSensorStorage { 301pub(crate) struct NumericSensorStorage {
296 pub state: Option<NumericSensorState>, 302 pub state: Option<NumericSensorState>,
297} 303}
298 304
299#[derive(Debug)] 305#[derive(Debug)]
300pub struct NumberState { 306pub(crate) struct NumberState {
301 pub value: f32, 307 pub value: f32,
308 #[allow(unused)]
302 pub timestamp: embassy_time::Instant, 309 pub timestamp: embassy_time::Instant,
303} 310}
304 311
305#[derive(Debug)] 312#[derive(Debug)]
306pub struct NumberCommand { 313pub(crate) struct NumberCommand {
307 pub value: f32, 314 pub value: f32,
315 #[allow(unused)]
308 pub timestamp: embassy_time::Instant, 316 pub timestamp: embassy_time::Instant,
309} 317}
310 318
311#[derive(Debug, Default)] 319#[derive(Debug, Default)]
312pub struct NumberStorage { 320pub(crate) struct NumberStorage {
313 pub state: Option<NumberState>, 321 pub state: Option<NumberState>,
314 pub command: Option<NumberCommand>, 322 pub command: Option<NumberCommand>,
315 pub publish_on_command: bool, 323 pub publish_on_command: bool,
316} 324}
317 325
318#[derive(Debug)] 326#[derive(Debug)]
319pub enum EntityStorage { 327pub(crate) enum EntityStorage {
320 Button(ButtonStorage), 328 Button(ButtonStorage),
321 Switch(SwitchStorage), 329 Switch(SwitchStorage),
322 BinarySensor(BinarySensorStorage), 330 BinarySensor(BinarySensorStorage),
@@ -369,7 +377,7 @@ struct EntityData {
369 command_waker: Option<Waker>, 377 command_waker: Option<Waker>,
370} 378}
371 379
372pub struct Entity<'a> { 380pub(crate) struct Entity<'a> {
373 pub(crate) data: &'a RefCell<Option<EntityData>>, 381 pub(crate) data: &'a RefCell<Option<EntityData>>,
374 pub(crate) waker: &'a AtomicWaker, 382 pub(crate) waker: &'a AtomicWaker,
375} 383}