Fix clippy warnings.

This commit is contained in:
Orne Brocaar 2022-05-24 16:15:12 +01:00
parent a0f56c0ff6
commit f4478864ee
3 changed files with 25 additions and 29 deletions

View File

@ -110,32 +110,27 @@ pub fn pb_json_to_prost(obj: &pbjson_types::Struct) -> prost_types::Struct {
fn _pb_json_to_prost(v: &pbjson_types::Value) -> prost_types::Value {
prost_types::Value {
kind: match &v.kind {
None => None,
Some(v) => Some(match v {
pbjson_types::value::Kind::NullValue(v) => prost_types::value::Kind::NullValue(*v),
pbjson_types::value::Kind::NumberValue(v) => {
prost_types::value::Kind::NumberValue(*v)
}
pbjson_types::value::Kind::StringValue(v) => {
prost_types::value::Kind::StringValue(v.to_string())
}
pbjson_types::value::Kind::BoolValue(v) => prost_types::value::Kind::BoolValue(*v),
pbjson_types::value::Kind::StructValue(v) => {
prost_types::value::Kind::StructValue(prost_types::Struct {
fields: v
.fields
.iter()
.map(|(k, v)| (k.to_string(), _pb_json_to_prost(v)))
.collect(),
})
}
pbjson_types::value::Kind::ListValue(v) => {
prost_types::value::Kind::ListValue(prost_types::ListValue {
values: v.values.iter().map(|i| _pb_json_to_prost(i)).collect(),
})
}
}),
},
kind: v.kind.as_ref().map(|v| match v {
pbjson_types::value::Kind::NullValue(v) => prost_types::value::Kind::NullValue(*v),
pbjson_types::value::Kind::NumberValue(v) => prost_types::value::Kind::NumberValue(*v),
pbjson_types::value::Kind::StringValue(v) => {
prost_types::value::Kind::StringValue(v.to_string())
}
pbjson_types::value::Kind::BoolValue(v) => prost_types::value::Kind::BoolValue(*v),
pbjson_types::value::Kind::StructValue(v) => {
prost_types::value::Kind::StructValue(prost_types::Struct {
fields: v
.fields
.iter()
.map(|(k, v)| (k.to_string(), _pb_json_to_prost(v)))
.collect(),
})
}
pbjson_types::value::Kind::ListValue(v) => {
prost_types::value::Kind::ListValue(prost_types::ListValue {
values: v.values.iter().map(_pb_json_to_prost).collect(),
})
}
}),
}
}

View File

@ -150,7 +150,7 @@ impl<'a> Integration<'a> {
info!("Starting MQTT consumer loop");
while let Some(msg_opt) = stream.next().await {
if let Some(msg) = msg_opt {
let caps = match command_regex.captures(&msg.topic()) {
let caps = match command_regex.captures(msg.topic()) {
Some(v) => v,
None => {
error!(topic = %msg.topic(), "Error parsing command topic (regex captures returned None)");
@ -398,7 +398,7 @@ async fn message_callback(
match command.as_ref() {
"down" => {
let cmd: integration::DownlinkCommand = match json {
true => serde_json::from_slice(&b)?,
true => serde_json::from_slice(b)?,
false => integration::DownlinkCommand::decode(&mut Cursor::new(b))?,
};
if dev_eui != cmd.dev_eui {

View File

@ -10,6 +10,7 @@ use tracing::info;
use crate::storage::{get_redis_conn, redis_key};
#[allow(clippy::upper_case_acronyms)]
#[allow(non_camel_case_types)]
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Eq, PartialEq)]
pub enum Aggregation {