Skip to content

Commit

Permalink
Remove ValueFailure
Browse files Browse the repository at this point in the history
  • Loading branch information
argerus committed Sep 24, 2024
1 parent 8fa5463 commit c9f1533
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 42 deletions.
2 changes: 0 additions & 2 deletions databroker/src/grpc/kuksa_val_v1/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ impl From<broker::Datapoint> for Option<proto::Datapoint> {
})),
timestamp: Some(from.ts.into()),
}),
broker::DataValue::ValueFailure(_) => None,
}
}
}
Expand Down Expand Up @@ -232,7 +231,6 @@ impl From<broker::DataValue> for Option<proto::Datapoint> {
})),
timestamp: None,
}),
broker::DataValue::ValueFailure(_) => None,
}
}
}
Expand Down
35 changes: 2 additions & 33 deletions databroker/src/grpc/kuksa_val_v2/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,6 @@ impl From<broker::Datapoint> for Option<proto::Datapoint> {
})),
timestamp: Some(from.ts.into()),
}),
broker::DataValue::ValueFailure(failure) => Some(proto::Datapoint {
value_state: Some(proto::datapoint::ValueState::Failure(i32::from(&failure))),
timestamp: Some(from.ts.into()),
}),
}
}
}
Expand All @@ -180,31 +176,6 @@ impl From<&broker::ValueFailure> for i32 {
}
}

impl From<&i32> for broker::ValueFailure {
fn from(from: &i32) -> Self {
match from {
1 => broker::ValueFailure::InvalidValue,
2 => broker::ValueFailure::NotProvided,
3 => broker::ValueFailure::UnknownSignal,
4 => broker::ValueFailure::AccessDenied,
5 => broker::ValueFailure::InternalError,
_ => broker::ValueFailure::Unspecified,
}
}
}

fn from_i32(value: i32) -> proto::ValueFailure {
// Use a match statement to convert the i32 to the corresponding enum variant
match value {
1 => proto::ValueFailure::InvalidValue,
2 => proto::ValueFailure::NotProvided,
3 => proto::ValueFailure::UnknownSignal,
4 => proto::ValueFailure::AccessDenied,
5 => proto::ValueFailure::InternalError,
_ => proto::ValueFailure::Unspecified,
}
}

impl From<&proto::ValueFailure> for broker::ValueFailure {
fn from(value_failure: &proto::ValueFailure) -> Self {
match value_failure {
Expand Down Expand Up @@ -256,11 +227,9 @@ impl From<&proto::Datapoint> for broker::DataValue {
Some(proto::value::TypedValue::DoubleArray(array)) => {
broker::DataValue::DoubleArray(array.values.clone())
}
None => todo!(),
None => broker::DataValue::NotAvailable,
},
Some(Failure(value)) => {
broker::DataValue::ValueFailure(broker::ValueFailure::from(&from_i32(*value)))
}
Some(Failure(_)) => broker::DataValue::NotAvailable,
None => broker::DataValue::NotAvailable,
}
}
Expand Down
6 changes: 0 additions & 6 deletions databroker/src/grpc/sdv_databroker_v1/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ impl From<&broker::Datapoint> for proto::Datapoint {
broker::DataValue::NotAvailable => proto::datapoint::Value::FailureValue(
proto::datapoint::Failure::NotAvailable as i32,
),
broker::DataValue::ValueFailure(_) => proto::datapoint::Value::FailureValue(
proto::datapoint::Failure::InternalError as i32,
),
};

proto::Datapoint {
Expand Down Expand Up @@ -169,9 +166,6 @@ impl From<&broker::QueryField> for proto::Datapoint {
broker::DataValue::NotAvailable => proto::datapoint::Value::FailureValue(
proto::datapoint::Failure::NotAvailable.into(),
),
broker::DataValue::ValueFailure(_) => proto::datapoint::Value::FailureValue(
proto::datapoint::Failure::InternalError.into(),
),
};

proto::Datapoint {
Expand Down
1 change: 0 additions & 1 deletion databroker/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ pub enum DataValue {
Uint64Array(Vec<u64>),
FloatArray(Vec<f32>),
DoubleArray(Vec<f64>),
ValueFailure(ValueFailure),
}

#[derive(Debug)]
Expand Down

0 comments on commit c9f1533

Please sign in to comment.