Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine payload value type based on enum #93

Open
pohlm01 opened this issue Nov 21, 2024 · 1 comment
Open

Determine payload value type based on enum #93

pohlm01 opened this issue Nov 21, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@pohlm01
Copy link
Member

pohlm01 commented Nov 21, 2024

For the payloads in the intervals, the data type of the value is determined by the type of the payload.
The VTN should make sure that the data type it expects for the provided type matches the one it received.

/// Represents one or more values associated with a type. E.g. a type of PRICE contains a single float value.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct EventValuesMap {
/// Enumerated or private string signifying the nature of values. E.G. \"PRICE\" indicates value is to be interpreted as a currency.
#[serde(rename = "type")]
pub value_type: EventType,
/// A list of data points. Most often a singular value such as a price.
// TODO: The type of Value is actually defined by value_type
pub values: Vec<Value>,
}

@pohlm01 pohlm01 added enhancement New feature or request good first issue Good for newcomers labels Nov 21, 2024
@pohlm01 pohlm01 moved this to Todo in OpenADR 3.0 Plan Nov 21, 2024
benjaminedwardwebb added a commit to benjaminedwardwebb/openleadr-rs that referenced this issue Jan 4, 2025
benjaminedwardwebb added a commit to benjaminedwardwebb/openleadr-rs that referenced this issue Jan 4, 2025
See OpenLEADR#93

Signed-off-by: Ben Webb <benjaminedwardwebb@gmail.com>
benjaminedwardwebb added a commit to benjaminedwardwebb/openleadr-rs that referenced this issue Jan 4, 2025
See OpenLEADR#93

Signed-off-by: Ben Webb <benjaminedwardwebb@gmail.com>
benjaminedwardwebb added a commit to benjaminedwardwebb/openleadr-rs that referenced this issue Jan 7, 2025
See OpenLEADR#93

Signed-off-by: Ben Webb <benjaminedwardwebb@gmail.com>
benjaminedwardwebb added a commit to benjaminedwardwebb/openleadr-rs that referenced this issue Jan 8, 2025
See OpenLEADR#93

Signed-off-by: Ben Webb <benjaminedwardwebb@gmail.com>
benjaminedwardwebb added a commit to benjaminedwardwebb/openleadr-rs that referenced this issue Jan 8, 2025
See OpenLEADR#93

Signed-off-by: Ben Webb <benjaminedwardwebb@gmail.com>
@pohlm01
Copy link
Member Author

pohlm01 commented Jan 9, 2025

@benjaminedwardwebb did a great job in #124 by validating if the type of the values matches what is expected from the value_type. Still, we keep this issue open as we strive for a cleaner version in the future: Instead of validating if the type is correct, we first want to parse it properly using a custom serde deserialize implementation. See the comments in #124 for the full insight.

github-merge-queue bot pushed a commit that referenced this issue Jan 9, 2025
* Validate event payload values match their type

See #93

Signed-off-by: Ben Webb <benjaminedwardwebb@gmail.com>

* Allow all values for private value types

Signed-off-by: Maximilian Pohl <maximilian@tweedegolf.com>

---------

Signed-off-by: Ben Webb <benjaminedwardwebb@gmail.com>
Signed-off-by: Maximilian Pohl <maximilian@tweedegolf.com>
Co-authored-by: Maximilian Pohl <maximilian@tweedegolf.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Status: Todo
Development

No branches or pull requests

1 participant