Skip to content
This repository has been archived by the owner on Dec 18, 2024. It is now read-only.

Support setting value "NotAvailable" #646

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions kuksa_databroker/databroker-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,12 @@ fn try_into_data_value(
input: &str,
data_type: proto::v1::DataType,
) -> Result<proto::v1::datapoint::Value, ParseError> {
if input == "NotAvailable" {
return Ok(proto::v1::datapoint::Value::FailureValue(
proto::v1::datapoint::Failure::NotAvailable as i32,
));
}

match data_type {
proto::v1::DataType::String => {
Ok(proto::v1::datapoint::Value::StringValue(input.to_owned()))
Expand Down
5 changes: 5 additions & 0 deletions kuksa_databroker/databroker/src/broker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,11 @@ impl Entry {
}

fn validate_value(&self, value: &DataValue) -> Result<(), UpdateError> {
// Not available is always valid
if value == &DataValue::NotAvailable {
return Ok(());
}

// Validate value
match self.metadata.data_type {
DataType::Bool => match value {
Expand Down