diff --git a/src/shadows/mod.rs b/src/shadows/mod.rs index 2825fd5..c508661 100644 --- a/src/shadows/mod.rs +++ b/src/shadows/mod.rs @@ -224,7 +224,7 @@ where } } - pub async fn delete_shadow(&mut self) -> Result<(), Error> { + pub async fn delete_shadow(&self) -> Result<(), Error> { // Wait for mqtt to connect self.mqtt.wait_connected().await; @@ -444,7 +444,7 @@ where } /// Get an immutable reference to the internal local state. - pub async fn try_get(&mut self) -> Result { + pub async fn try_get(&self) -> Result { self.dao.lock().await.read().await } @@ -465,6 +465,14 @@ where Ok(state) } + /// Report the state of the shadow. + pub async fn report(&self) -> Result<(), Error> { + let state = self.dao.lock().await.read().await?; + + self.handler.report(&state).await?; + Ok(()) + } + /// Update the state of the shadow. /// /// This function will update the desired state of the shadow in the cloud, @@ -491,7 +499,7 @@ where Ok(()) } - pub async fn delete_shadow(&mut self) -> Result<(), Error> { + pub async fn delete_shadow(&self) -> Result<(), Error> { self.handler.delete_shadow().await?; self.dao.lock().await.write(&S::default()).await?; Ok(())