Skip to content

Commit

Permalink
Merge pull request #354 from rgallor/fwp-0.8.2
Browse files Browse the repository at this point in the history
Forward port v0.8.2
  • Loading branch information
harlem88 authored May 29, 2024
2 parents 9cbf280 + a7cc3a1 commit aff73f2
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 22 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Update the Dynamic Introspection to support adding or removing interfaces from a MessageHub Node [#330](https://github.com/astarte-platform/astarte-device-sdk-rust/issues/330)

## [0.8.2] - 2024-05-29

## [0.7.4] - 2024-05-27

## [0.6.6] - 2024-05-27

## [0.5.4] - 2024-05-22
### Fixed
- Purge property deletes only the server property [#342](https://github.com/astarte-platform/astarte-device-sdk-rust/pull/342)

## [0.8.1] - 2024-05-03
### Fixed
- Correct the interfaces iterator logic to send the correct device
Expand Down
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ members = [
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[workspace.package]
version = "0.8.1"
version = "0.8.2"
edition = "2021"
homepage = "https://astarte.cloud/"
license = "Apache-2.0"
Expand Down Expand Up @@ -104,8 +104,8 @@ interface-doc = []
interface-strict = []

[workspace.dependencies]
astarte-device-sdk = { path = "./", version = "=0.8.1" }
astarte-device-sdk-derive = { version = "=0.8.1", path = "./astarte-device-sdk-derive" }
astarte-device-sdk = { path = "./", version = "=0.8.2" }
astarte-device-sdk-derive = { version = "=0.8.2", path = "./astarte-device-sdk-derive" }
astarte-message-hub-proto = { git = "https://github.com/astarte-platform/astarte-message-hub-proto"}
async-trait = "0.1.50"
base64 = "0.22.0"
Expand Down
8 changes: 8 additions & 0 deletions astarte-device-sdk-derive/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.2] - 2024-05-29

## [0.7.4] - 2024-05-27

## [0.6.6] - 2024-05-27

## [0.5.4] - 2024-05-22

## [0.8.1] - 2024-05-03

## [0.8.0] - 2024-04-29
Expand Down
2 changes: 2 additions & 0 deletions astarte-device-sdk-mock/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.8.2] - 2024-05-29

## [0.8.1] - 2024-05-03
24 changes: 18 additions & 6 deletions astarte-device-sdk-mock/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

use std::path::Path;

use astarte_device_sdk::{AstarteAggregate, AstarteType, DeviceEvent, Error, Interface};
use astarte_device_sdk::{
properties::PropAccess, store::StoredProp, AstarteAggregate, AstarteType, DeviceEvent, Error,
Interface,
};
use async_trait::async_trait;
use mockall::mock;

Expand Down Expand Up @@ -109,10 +112,10 @@ pub trait DynamicIntrospection {
}

mock! {
pub DeviceClient<C: 'static> { }
pub DeviceClient<S: 'static> { }

#[async_trait]
impl<C: Send + Sync> Client for DeviceClient<C> {
impl<S: Send + Sync> Client for DeviceClient<S> {
async fn send_object_with_timestamp<D>(
&self,
interface_name: &str,
Expand Down Expand Up @@ -158,15 +161,15 @@ mock! {


#[async_trait]
impl<C: Send + Sync> DeviceIntrospection for DeviceClient<C> {
impl<S: Send + Sync> DeviceIntrospection for DeviceClient<S> {
async fn get_interface<F, O>(&self, interface_name: &str, f: F) -> O
where
F: FnMut(Option<&Interface>) -> O + Send + 'static,
O: 'static;
}

#[async_trait]
impl<C: Send + Sync> DynamicIntrospection for DeviceClient<C> {
impl<S: Send + Sync> DynamicIntrospection for DeviceClient<S> {
async fn add_interface(&self, interface: Interface) -> Result<bool, Error>;

async fn extend_interfaces<I>(&self, interfaces: I) -> Result<Vec<String>, Error>
Expand All @@ -191,7 +194,16 @@ mock! {
async fn remove_interfaces_vec(&self, interfaces_name: Vec<String>) -> Result<Vec<String>, Error>;
}

impl<C> Clone for DeviceClient<C> {
#[async_trait]
impl<S: Send + Sync> PropAccess for DeviceClient<S> {
async fn property(&self, interface: &str, path: &str) -> Result<Option<AstarteType>, Error>;
async fn interface_props(&self, interface: &str) -> Result<Vec<StoredProp>, Error>;
async fn all_props(&self) -> Result<Vec<StoredProp>, Error>;
async fn device_props(&self) -> Result<Vec<StoredProp>, Error>;
async fn server_props(&self) -> Result<Vec<StoredProp>, Error>;
}

impl<S> Clone for DeviceClient<S> {
fn clone(&self) -> Self {}
}
}
Expand Down
16 changes: 11 additions & 5 deletions src/transport/mqtt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,20 @@ impl Mqtt {
Ok(())
}

/// Purges local properties defined in the passed binary data
async fn purge_properties<S>(&self, store: &StoreWrapper<S>, bdata: &[u8]) -> Result<(), Error>
/// This function deletes all the stored server owned properties after receiving a publish on
/// `/control/consumer/properties`
async fn purge_server_properties<S>(
&self,
store: &StoreWrapper<S>,
bdata: &[u8],
) -> Result<(), Error>
where
S: PropertyStore,
{
let stored_props = store.load_all_props().await?;

let paths = properties::extract_set_properties(bdata)?;

let stored_props = store.server_props().await?;

for stored_prop in stored_props {
if paths.contains(&format!("{}{}", stored_prop.interface, stored_prop.path)) {
continue;
Expand Down Expand Up @@ -496,7 +501,8 @@ impl Receive for Mqtt {
if purge_topic == &publish.topic {
debug!("Purging properties");

self.purge_properties(store, &publish.payload).await?;
self.purge_server_properties(store, &publish.payload)
.await?;
} else {
let client_id = CLIENT_ID.get_or_init(|| self.client_id().to_string());
let ParsedTopic { interface, path } =
Expand Down

0 comments on commit aff73f2

Please sign in to comment.