Skip to content

Commit 3b9b3ea

Browse files
Refactor EVChargerType enum variants (#21)
The enum with the oder variants was compiled into the following rust enum (by prost): ```rust pub enum EvChargerType { /// Default type. EvchargerTypeUnspecified = 0, /// The EV charging station supports AC charging only. EvchargerTypeAc = 1, /// The EV charging station supports DC charging only. EvchargerTypeDc = 2, /// The EV charging station supports both AC and DC. EvchargerTypeHybrid = 3, } ``` Here the enum variants were unnecessarily prefixed with `EvchargerType`. This lead to accessing the enum variants in a very verbose manner, e.g., `EvChargerType::EvchargerTypeHybrid`. The changed version of the enum in this commit results in the following rust enum: ```rust pub enum EvChargerType { /// Default type. Unspecified = 0, /// The EV charging station supports AC charging only. Ac = 1, /// The EV charging station supports DC charging only. Dc = 2, /// The EV charging station supports both AC and DC. Hybrid = 3, } ``` Here the unnecessary prefix `EvchargerType` is absent. This reduces the verbosity while accessing the enum variants, making the resulting rust code more readable, e.g., as `EvChargerType::Hybrid`.
2 parents d8d712f + ead1927 commit 3b9b3ea

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed

RELEASE_NOTES.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,46 @@
1515
Synchronizing submodule url for 'submodules/api-common-protos'
1616
```
1717

18+
* [`EVChargerType` enum refactored](https://github.com/frequenz-floss/frequenz-api-common/pull/21)
19+
20+
The enum with the oder variants was compiled into the following rust enum
21+
(by prost):
22+
```rust
23+
pub enum EvChargerType {
24+
/// Default type.
25+
EvchargerTypeUnspecified = 0,
26+
/// The EV charging station supports AC charging only.
27+
EvchargerTypeAc = 1,
28+
/// The EV charging station supports DC charging only.
29+
EvchargerTypeDc = 2,
30+
/// The EV charging station supports both AC and DC.
31+
EvchargerTypeHybrid = 3,
32+
}
33+
```
34+
Here the enum variants were unnecessarily prefixed with `EvchargerType`.
35+
This lead to accessing the enum variants in a very verbose manner, e.g.,
36+
`EvChargerType::EvchargerTypeHybrid`.
37+
38+
The changed version of the enum in this commit results in the following
39+
rust enum:
40+
```rust
41+
pub enum EvChargerType {
42+
/// Default type.
43+
Unspecified = 0,
44+
/// The EV charging station supports AC charging only.
45+
Ac = 1,
46+
/// The EV charging station supports DC charging only.
47+
Dc = 2,
48+
/// The EV charging station supports both AC and DC.
49+
Hybrid = 3,
50+
}
51+
```
52+
Here the unnecessary prefix `EvchargerType` is absent. This reduces the
53+
verbosity while accessing the enum variants, making the resulting rust code
54+
more readable, e.g., as `EvChargerType::Hybrid`.
55+
56+
This change also leads to renaming the enum from `EVChargerType` to
57+
`EvChargerType`, to satisfy protolint requirements.
1858
## New Features
1959

2060
<!-- Here goes the main new features and examples or instructions on how to use them -->

proto/frequenz/api/common/components.proto

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,18 @@ enum InverterType {
7575
}
7676

7777
// Enumerated EV charger types.
78-
enum EVChargerType {
78+
enum EvChargerType {
7979
// Default type.
80-
EVCHARGER_TYPE_UNSPECIFIED = 0;
80+
EV_CHARGER_TYPE_UNSPECIFIED = 0;
8181

8282
// The EV charging station supports AC charging only.
83-
EVCHARGER_TYPE_AC = 1;
83+
EV_CHARGER_TYPE_AC = 1;
8484

8585
// The EV charging station supports DC charging only.
86-
EVCHARGER_TYPE_DC = 2;
86+
EV_CHARGER_TYPE_DC = 2;
8787

8888
// The EV charging station supports both AC and DC.
89-
EVCHARGER_TYPE_HYBRID = 3;
89+
EV_CHARGER_TYPE_HYBRID = 3;
9090
}
9191

9292
// Enumerated sensor types.

0 commit comments

Comments
 (0)