codelabsab / rust-ocpp

Libraries for ocpp 1.6 and 2.0.1
https://docs.rs/rust-ocpp/latest/rust_ocpp/
Apache License 2.0
67 stars 16 forks source link

Feature/default derive #13

Closed larsk2009 closed 1 year ago

larsk2009 commented 1 year ago

Fixes #12.

I updated the unit tests to use the defaults where possible (not possible for arrays, as you get empty arrays). Maybe you don't want this as you might want all options to be Some where default will make them None. If so, I can remove #30848bc from this PR.

I also noticed one bug after using the default types in the unit tests. The status notification timestamp was missing a skip_serializing_if for the option type. That is also fixed in this PR.

codecov-commenter commented 1 year ago

Codecov Report

Base: 84.14% // Head: 77.61% // Decreases project coverage by -6.53% :warning:

Coverage data is based on head (4594806) compared to base (4cd78f9). Patch coverage: 87.58% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #13 +/- ## ========================================== - Coverage 84.14% 77.61% -6.54% ========================================== Files 281 281 Lines 4832 3596 -1236 ========================================== - Hits 4066 2791 -1275 - Misses 766 805 +39 ``` | [Impacted Files](https://codecov.io/gh/codelabsab/rust-ocpp/pull/13?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codelabsab) | Coverage Δ | | |---|---|---| | [src/tests/schema\_validation/v2\_0\_1.rs](https://codecov.io/gh/codelabsab/rust-ocpp/pull/13/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codelabsab#diff-c3JjL3Rlc3RzL3NjaGVtYV92YWxpZGF0aW9uL3YyXzBfMS5ycw==) | `77.26% <ø> (-7.15%)` | :arrow_down: | | [src/v1\_6/types/authorization\_data.rs](https://codecov.io/gh/codelabsab/rust-ocpp/pull/13/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codelabsab#diff-c3JjL3YxXzYvdHlwZXMvYXV0aG9yaXphdGlvbl9kYXRhLnJz) | `0.00% <0.00%> (ø)` | | | [src/v1\_6/types/charging\_schedule\_period.rs](https://codecov.io/gh/codelabsab/rust-ocpp/pull/13/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codelabsab#diff-c3JjL3YxXzYvdHlwZXMvY2hhcmdpbmdfc2NoZWR1bGVfcGVyaW9kLnJz) | `0.00% <0.00%> (-100.00%)` | :arrow_down: | | [src/v1\_6/types/key\_value.rs](https://codecov.io/gh/codelabsab/rust-ocpp/pull/13/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codelabsab#diff-c3JjL3YxXzYvdHlwZXMva2V5X3ZhbHVlLnJz) | `0.00% <0.00%> (-100.00%)` | :arrow_down: | | [src/v1\_6/types/location.rs](https://codecov.io/gh/codelabsab/rust-ocpp/pull/13/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codelabsab#diff-c3JjL3YxXzYvdHlwZXMvbG9jYXRpb24ucnM=) | `0.00% <0.00%> (ø)` | | | [src/v1\_6/types/measurand.rs](https://codecov.io/gh/codelabsab/rust-ocpp/pull/13/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codelabsab#diff-c3JjL3YxXzYvdHlwZXMvbWVhc3VyYW5kLnJz) | `0.00% <0.00%> (ø)` | | | [src/v1\_6/types/meter\_value.rs](https://codecov.io/gh/codelabsab/rust-ocpp/pull/13/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codelabsab#diff-c3JjL3YxXzYvdHlwZXMvbWV0ZXJfdmFsdWUucnM=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: | | [src/v1\_6/types/phase.rs](https://codecov.io/gh/codelabsab/rust-ocpp/pull/13/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codelabsab#diff-c3JjL3YxXzYvdHlwZXMvcGhhc2UucnM=) | `0.00% <0.00%> (ø)` | | | [src/v1\_6/types/reading\_context.rs](https://codecov.io/gh/codelabsab/rust-ocpp/pull/13/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codelabsab#diff-c3JjL3YxXzYvdHlwZXMvcmVhZGluZ19jb250ZXh0LnJz) | `0.00% <0.00%> (ø)` | | | [src/v1\_6/types/reason.rs](https://codecov.io/gh/codelabsab/rust-ocpp/pull/13/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codelabsab#diff-c3JjL3YxXzYvdHlwZXMvcmVhc29uLnJz) | `0.00% <0.00%> (ø)` | | | ... and [270 more](https://codecov.io/gh/codelabsab/rust-ocpp/pull/13/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codelabsab) | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codelabsab). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=codelabsab)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

tommymalmqvist commented 1 year ago

Thank you for the PR @larsk2009

I think we should drop #30848bc since using full nested structs is more extensive.

Also, nice find with #4594806

larsk2009 commented 1 year ago

Okay, I'll remove that commit