astarte-platform / astarte-device-sdk-rust

Apache License 2.0
6 stars 12 forks source link

refactor(unset): remove the AstarteType::Unset #296

Closed joshuachp closed 7 months ago

joshuachp commented 7 months ago

Move the Unset to the Aggregation enum and introduce a new unset method. This simplify the checks since you can only unset a property and the AstarteType::Unset is not needed in the others code paths. Also this simplifies the conversions in the gRPC code that now in infallible.

codecov[bot] commented 7 months ago

Codecov Report

Attention: Patch coverage is 73.97260% with 57 lines in your changes are missing coverage. Please review.

Project coverage is 67.9%. Comparing base (fb0bc2f) to head (65a6692). Report is 1 commits behind head on master.

Additional details and impacted files | [Files](https://app.codecov.io/gh/astarte-platform/astarte-device-sdk-rust/pull/296?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astarte-platform) | Coverage Δ | | |---|---|---| | [astarte-device-sdk-derive/src/lib.rs](https://app.codecov.io/gh/astarte-platform/astarte-device-sdk-rust/pull/296?src=pr&el=tree&filepath=astarte-device-sdk-derive%2Fsrc%2Flib.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astarte-platform#diff-YXN0YXJ0ZS1kZXZpY2Utc2RrLWRlcml2ZS9zcmMvbGliLnJz) | `0.0% <ø> (ø)` | | | [src/interface/mapping/path.rs](https://app.codecov.io/gh/astarte-platform/astarte-device-sdk-rust/pull/296?src=pr&el=tree&filepath=src%2Finterface%2Fmapping%2Fpath.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astarte-platform#diff-c3JjL2ludGVyZmFjZS9tYXBwaW5nL3BhdGgucnM=) | `61.8% <ø> (ø)` | | | [src/interface/mod.rs](https://app.codecov.io/gh/astarte-platform/astarte-device-sdk-rust/pull/296?src=pr&el=tree&filepath=src%2Finterface%2Fmod.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astarte-platform#diff-c3JjL2ludGVyZmFjZS9tb2QucnM=) | `77.3% <100.0%> (ø)` | | | [src/interfaces.rs](https://app.codecov.io/gh/astarte-platform/astarte-device-sdk-rust/pull/296?src=pr&el=tree&filepath=src%2Finterfaces.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astarte-platform#diff-c3JjL2ludGVyZmFjZXMucnM=) | `77.8% <100.0%> (ø)` | | | [src/store/mod.rs](https://app.codecov.io/gh/astarte-platform/astarte-device-sdk-rust/pull/296?src=pr&el=tree&filepath=src%2Fstore%2Fmod.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astarte-platform#diff-c3JjL3N0b3JlL21vZC5ycw==) | `100.0% <100.0%> (ø)` | | | [src/types.rs](https://app.codecov.io/gh/astarte-platform/astarte-device-sdk-rust/pull/296?src=pr&el=tree&filepath=src%2Ftypes.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astarte-platform#diff-c3JjL3R5cGVzLnJz) | `88.9% <ø> (+1.2%)` | :arrow_up: | | [src/store/sqlite.rs](https://app.codecov.io/gh/astarte-platform/astarte-device-sdk-rust/pull/296?src=pr&el=tree&filepath=src%2Fstore%2Fsqlite.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astarte-platform#diff-c3JjL3N0b3JlL3NxbGl0ZS5ycw==) | `90.8% <66.6%> (-0.3%)` | :arrow_down: | | [src/transport/mqtt/mod.rs](https://app.codecov.io/gh/astarte-platform/astarte-device-sdk-rust/pull/296?src=pr&el=tree&filepath=src%2Ftransport%2Fmqtt%2Fmod.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astarte-platform#diff-c3JjL3RyYW5zcG9ydC9tcXR0L21vZC5ycw==) | `72.5% <85.7%> (+0.3%)` | :arrow_up: | | [src/transport/mqtt/payload.rs](https://app.codecov.io/gh/astarte-platform/astarte-device-sdk-rust/pull/296?src=pr&el=tree&filepath=src%2Ftransport%2Fmqtt%2Fpayload.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astarte-platform#diff-c3JjL3RyYW5zcG9ydC9tcXR0L3BheWxvYWQucnM=) | `74.4% <50.0%> (+0.9%)` | :arrow_up: | | [src/interface/reference.rs](https://app.codecov.io/gh/astarte-platform/astarte-device-sdk-rust/pull/296?src=pr&el=tree&filepath=src%2Finterface%2Freference.rs&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astarte-platform#diff-c3JjL2ludGVyZmFjZS9yZWZlcmVuY2UucnM=) | `70.0% <73.3%> (-2.8%)` | :arrow_down: | | ... and [5 more](https://app.codecov.io/gh/astarte-platform/astarte-device-sdk-rust/pull/296?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=astarte-platform) | |
joshuachp commented 7 months ago

I propose the Value for the name of the Aggregate, this is the same name in the MQTT protocol (the v field of the bson document).

This is because we are already "over-using" payload as the name of the body of a message/request in the transport structs.