Update Rust toolchain + fix Clippy feedback.

This commit is contained in:
Orne Brocaar 2025-01-13 12:16:15 +00:00
parent 2e738e1f33
commit a71113db42
20 changed files with 35 additions and 40 deletions

5
api/rust/build.rs vendored
View File

@ -82,11 +82,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.extern_path(".google.protobuf", well_known_types_path)
.extern_path(".common", "crate::common");
#[cfg(feature = "diesel")]
{
builder = builder.message_attribute("internal.DeviceSession", "#[derive(diesel::expression::AsExpression, diesel::deserialize::FromSqlRow)] #[diesel(sql_type = diesel::sql_types::Binary)]");
}
builder.compile_protos(
&[cs_dir
.join("internal")

View File

@ -21,7 +21,7 @@ impl Plugin {
let m = rquickjs::Module::declare(ctx, "script", script.clone())
.context("Declare script")?;
let (m, m_promise) = m.eval().context("Evaluate script")?;
m_promise.finish()?;
() = m_promise.finish()?;
let id_func: rquickjs::Function = m.get("id").context("Get id function")?;
let name_func: rquickjs::Function = m.get("name").context("Get name function")?;
@ -55,7 +55,7 @@ impl Handler for Plugin {
let m = rquickjs::Module::declare(ctx.clone(), "script", self.script.clone())
.context("Declare script")?;
let (m, m_promise) = m.eval().context("Evaluate script")?;
m_promise.finish()?;
() = m_promise.finish()?;
let func: rquickjs::Function = m.get("handle").context("Get handle function")?;
let device_variables = rquickjs::Object::new(ctx.clone())?;

View File

@ -601,7 +601,7 @@ async fn handle_async_ans(bp: &BasePayload, b: &[u8]) -> Result<Response> {
let key = redis_key(format!("backend:async:{}", transaction_id));
redis::pipe()
() = redis::pipe()
.atomic()
.cmd("XADD")
.arg(&key)

View File

@ -162,7 +162,7 @@ async fn store_verifier(
trace!("Storing verifier");
let key = redis_key(format!("auth:oauth2:{}", token.secret()));
redis::cmd("PSETEX")
() = redis::cmd("PSETEX")
.arg(key)
.arg(Duration::try_minutes(5).unwrap().num_milliseconds())
.arg(verifier.secret())

View File

@ -119,7 +119,7 @@ async fn store_nonce(state: &CsrfToken, nonce: &Nonce) -> Result<()> {
trace!("Storing nonce");
let key = redis_key(format!("auth:oidc:{}", state.secret()));
redis::cmd("PSETEX")
() = redis::cmd("PSETEX")
.arg(key)
.arg(Duration::try_minutes(5).unwrap().num_milliseconds())
.arg(nonce.secret())

View File

@ -63,7 +63,7 @@ pub async fn decode(
.eval()
.catch(&ctx)
.map_err(|e| anyhow!("JS error: {}", e))?;
buff_promise.finish()?;
() = buff_promise.finish()?;
let buff: rquickjs::Function = buff.get("Buffer")?;
let input = rquickjs::Object::new(ctx.clone())?;
@ -154,7 +154,7 @@ pub async fn encode(
.eval()
.catch(&ctx)
.map_err(|e| anyhow!("JS error: {}", e))?;
buff_promise.finish()?;
() = buff_promise.finish()?;
let buff: rquickjs::Function = buff.get("Buffer")?;
let input = rquickjs::Object::new(ctx.clone())?;

View File

@ -39,7 +39,7 @@ impl<'a> Integration<'a> {
templates.register_template_string("event_key", &conf.event_key)?;
let producer: FutureProducer = ClientConfig::new()
.set("bootstrap.servers", &conf.brokers.join(","))
.set("bootstrap.servers", conf.brokers.join(","))
.set("message.timeout.ms", "5000")
.set("allow.auto.create.topics", "true")
.set(

View File

@ -86,7 +86,7 @@ pub async fn save_geoloc_buffer(
};
let b = buffer.encode_to_vec();
redis::cmd("PSETEX")
() = redis::cmd("PSETEX")
.arg(key)
.arg(ttl.num_milliseconds())
.arg(b)

View File

@ -16,7 +16,7 @@ pub async fn save_rx_info(rx_info: &internal::DeviceGatewayRxInfo) -> Result<()>
let ttl = conf.network.device_session_ttl.as_millis() as usize;
let b = rx_info.encode_to_vec();
redis::cmd("PSETEX")
() = redis::cmd("PSETEX")
.arg(key)
.arg(ttl)
.arg(b)

View File

@ -11,7 +11,7 @@ pub async fn save(df: &internal::DownlinkFrame) -> Result<()> {
let b = df.encode_to_vec();
let key = redis_key(format!("frame:{}", df.downlink_id));
redis::cmd("SETEX")
() = redis::cmd("SETEX")
.arg(key)
.arg(30)
.arg(b)

View File

@ -12,7 +12,7 @@ pub async fn set_pending(dev_eui: &EUI64, cid: lrwn::CID, set: &lrwn::MACCommand
let ttl = conf.network.device_session_ttl.as_millis() as usize;
let b = set.to_vec()?;
redis::cmd("PSETEX")
() = redis::cmd("PSETEX")
.arg(key)
.arg(ttl)
.arg(b)
@ -48,7 +48,7 @@ pub async fn get_pending(dev_eui: &EUI64, cid: lrwn::CID) -> Result<Option<lrwn:
pub async fn delete_pending(dev_eui: &EUI64, cid: lrwn::CID) -> Result<()> {
let key = redis_key(format!("device:{}:mac:pending:{}", dev_eui, cid.to_u8()));
redis::cmd("DEL")
() = redis::cmd("DEL")
.arg(key)
.query_async(&mut get_async_redis_conn().await?)
.await?;

View File

@ -78,7 +78,7 @@ pub async fn save_state(name: &str, state: &str) -> Result<()> {
let key = redis_key(format!("metrics:{{{}}}", name));
let ttl = get_ttl(Aggregation::MONTH);
redis::cmd("PSETEX")
() = redis::cmd("PSETEX")
.arg(key)
.arg(ttl.as_millis() as usize)
.arg(state)
@ -160,7 +160,7 @@ pub async fn save(name: &str, record: &Record, aggregations: &[Aggregation]) ->
info!(name = %name, aggregation = %a, "Metrics saved");
}
pipe.query_async(&mut get_async_redis_conn().await?).await?;
() = pipe.query_async(&mut get_async_redis_conn().await?).await?;
Ok(())
}

View File

@ -226,7 +226,7 @@ pub async fn reset_db() -> Result<()> {
#[cfg(test)]
pub async fn reset_redis() -> Result<()> {
redis::cmd("FLUSHDB")
() = redis::cmd("FLUSHDB")
.query_async(&mut get_async_redis_conn().await?)
.await?;
Ok(())

View File

@ -55,15 +55,15 @@ pub async fn save(ds: &internal::PassiveRoamingDeviceSession) -> Result<()> {
// * We need to be able to lookup the session using the DevAddr (potentially
// using the MIC validation).
// * We need to be able to stop a passive-roaming session given a DevEUI.
redis::pipe()
() = redis::pipe()
.atomic()
.cmd("SADD")
.arg(&dev_addr_key)
.arg(&sess_id.to_string())
.arg(sess_id.to_string())
.ignore()
.cmd("SADD")
.arg(&dev_eui_key)
.arg(&sess_id.to_string())
.arg(sess_id.to_string())
.ignore()
.cmd("PEXPIRE")
.arg(&dev_addr_key)
@ -105,7 +105,7 @@ pub async fn get(id: Uuid) -> Result<internal::PassiveRoamingDeviceSession, Erro
pub async fn delete(id: Uuid) -> Result<()> {
let key = redis_key(format!("pr:sess:{{{}}}", id));
redis::cmd("DEL")
() = redis::cmd("DEL")
.arg(&key)
.query_async(&mut get_async_redis_conn().await?)
.await?;

View File

@ -14,7 +14,7 @@ pub async fn log_request(pl: &stream::ApiRequestLog) -> Result<()> {
let key = redis_key("api:stream:request".to_string());
let b = pl.encode_to_vec();
redis::cmd("XADD")
() = redis::cmd("XADD")
.arg(&key)
.arg("MAXLEN")
.arg(conf.monitoring.api_request_log_max_history)

View File

@ -37,7 +37,7 @@ pub async fn log_request(pl: stream::BackendInterfacesRequest) -> Result<()> {
let key = redis_key("backend_interfaces:stream:request".to_string());
let b = pl.encode_to_vec();
redis::cmd("XADD")
() = redis::cmd("XADD")
.arg(&key)
.arg("MAXLEN")
.arg(conf.monitoring.backend_interfaces_log_max_history)

View File

@ -21,7 +21,7 @@ pub async fn log_event_for_device(typ: &str, dev_eui: &str, b: &[u8]) -> Result<
// per device stream
if conf.monitoring.per_device_event_log_max_history > 0 {
let key = redis_key(format!("device:{{{}}}:stream:event", dev_eui));
redis::pipe()
() = redis::pipe()
.atomic()
.cmd("XADD")
.arg(&key)
@ -42,7 +42,7 @@ pub async fn log_event_for_device(typ: &str, dev_eui: &str, b: &[u8]) -> Result<
// global device stream
if conf.monitoring.device_event_log_max_history > 0 {
let key = redis_key("device:stream:event".to_string());
redis::cmd("XADD")
() = redis::cmd("XADD")
.arg(&key)
.arg("MAXLEN")
.arg(conf.monitoring.device_event_log_max_history)

View File

@ -41,7 +41,7 @@ pub async fn log_uplink_for_gateways(ufl: &stream::UplinkFrameLog) -> Result<()>
if conf.monitoring.per_gateway_frame_log_max_history > 0 {
let key = redis_key(format!("gw:{{{}}}:stream:frame", gateway_id));
redis::pipe()
() = redis::pipe()
.atomic()
.cmd("XADD")
.arg(&key)
@ -62,7 +62,7 @@ pub async fn log_uplink_for_gateways(ufl: &stream::UplinkFrameLog) -> Result<()>
// global gateway stream
if conf.monitoring.gateway_frame_log_max_history > 0 {
let key = redis_key("gw:stream:frame".to_string());
redis::cmd("XADD")
() = redis::cmd("XADD")
.arg(&key)
.arg("MAXLEN")
.arg(conf.monitoring.gateway_frame_log_max_history)
@ -89,7 +89,7 @@ pub async fn log_downlink_for_gateway(dfl: &stream::DownlinkFrameLog) -> Result<
// per gateway stream
if conf.monitoring.per_gateway_frame_log_max_history > 0 {
let key = redis_key(format!("gw:{{{}}}:stream:frame", dfl.gateway_id));
redis::pipe()
() = redis::pipe()
.atomic()
.cmd("XADD")
.arg(&key)
@ -110,7 +110,7 @@ pub async fn log_downlink_for_gateway(dfl: &stream::DownlinkFrameLog) -> Result<
// global gateway stream
if conf.monitoring.gateway_frame_log_max_history > 0 {
let key = redis_key("gw:stream:frame".to_string());
redis::cmd("XADD")
() = redis::cmd("XADD")
.arg(&key)
.arg("MAXLEN")
.arg(conf.monitoring.gateway_frame_log_max_history)
@ -137,7 +137,7 @@ pub async fn log_uplink_for_device(ufl: &stream::UplinkFrameLog) -> Result<()> {
if conf.monitoring.per_device_frame_log_max_history > 0 {
let key = redis_key(format!("device:{{{}}}:stream:frame", ufl.dev_eui));
redis::pipe()
() = redis::pipe()
.atomic()
.cmd("XADD")
.arg(&key)
@ -158,7 +158,7 @@ pub async fn log_uplink_for_device(ufl: &stream::UplinkFrameLog) -> Result<()> {
// global device stream
if conf.monitoring.device_frame_log_max_history > 0 {
let key = redis_key("device:stream:frame".to_string());
redis::cmd("XADD")
() = redis::cmd("XADD")
.arg(&key)
.arg("MAXLEN")
.arg(conf.monitoring.device_frame_log_max_history)
@ -185,7 +185,7 @@ pub async fn log_downlink_for_device(dfl: &stream::DownlinkFrameLog) -> Result<(
if conf.monitoring.per_device_frame_log_max_history > 0 {
let key = redis_key(format!("device:{{{}}}:stream:frame", dfl.dev_eui));
redis::pipe()
() = redis::pipe()
.atomic()
.cmd("XADD")
.arg(&key)
@ -206,7 +206,7 @@ pub async fn log_downlink_for_device(dfl: &stream::DownlinkFrameLog) -> Result<(
// global device stream
if conf.monitoring.device_frame_log_max_history > 0 {
let key = redis_key("device:stream:frame".to_string());
redis::cmd("XADD")
() = redis::cmd("XADD")
.arg(&key)
.arg("MAXLEN")
.arg(conf.monitoring.device_frame_log_max_history)

View File

@ -11,7 +11,7 @@ pub async fn log_uplink(up: &stream::UplinkMeta) -> Result<()> {
if conf.monitoring.meta_log_max_history > 0 {
let key = redis_key("stream:meta".to_string());
let b = up.encode_to_vec();
redis::cmd("XADD")
() = redis::cmd("XADD")
.arg(&key)
.arg("MAXLEN")
.arg(conf.monitoring.meta_log_max_history)
@ -32,7 +32,7 @@ pub async fn log_downlink(down: &stream::DownlinkMeta) -> Result<()> {
let key = redis_key("stream:meta".to_string());
let b = down.encode_to_vec();
redis::cmd("XADD")
() = redis::cmd("XADD")
.arg(&key)
.arg("MAXLEN")
.arg(conf.monitoring.meta_log_max_history)

View File

@ -1,4 +1,4 @@
[toolchain]
channel = "1.79.0"
channel = "1.81.0"
components = ["rustfmt", "clippy"]
profile = "default"