Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
XdoctorwhoZ committed Aug 3, 2024
1 parent d742665 commit 51aa14b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
7 changes: 7 additions & 0 deletions src/asyncv/attribute/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ pub use super::AttributeBuilder;

pub type MessageClient = rumqttc::AsyncClient;

pub type AttributeId = u32;

/// Trait to manage an message attribute (MQTT)
/// Sync version
#[async_trait]
pub trait OnMessageHandler: Send + Sync {
async fn on_message(&mut self, data: &Bytes);
}

#[async_trait]
pub trait OnMessageBoolean: Send + Sync {
async fn on_message_boolean(&mut self, id: AttributeId, data: bool);
}
20 changes: 10 additions & 10 deletions src/asyncv/attribute/message/boolean/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ impl AttributeBoolean {

/// Set the value of the attribute
///
// pub async fn set(&self, value: bool) -> Result<(), AttributeError> {
// self.inner.lock().await.set(value).await?;
// // let cv = self.inner.lock().await.set_ensure_lock_clone();
// // cv.with_lock(|mut done| {
// // while !*done {
// // done.wait();
// // }
// // });
// // Ok(())
// }
pub async fn set(&self, value: bool) -> Result<(), AttributeError> {
self.inner.lock().await.set(value).await?;
// let cv = self.inner.lock().await.set_ensure_lock_clone();
// cv.with_lock(|mut done| {
// while !*done {
// done.wait();
// }
// });
Ok(())
}

/// Get the value of the attribute
///
Expand Down
1 change: 1 addition & 0 deletions src/asyncv/attribute/message/boolean/attribute/inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use monitor::Monitor;
/// Inner implementation of the boolean message attribute
///
pub struct InnerBoolean {
id: AttributeId,
/// Members at the core of each attribute
core: MessageCoreMembers,
/// Current value of the attribute
Expand Down

0 comments on commit 51aa14b

Please sign in to comment.