From e3e1c4a5b9a8ee26928ed9d87886ad10a67fd14c Mon Sep 17 00:00:00 2001 From: Mika Date: Mon, 14 Oct 2024 00:16:29 +0200 Subject: [PATCH] fix warnings --- crates/backend/src/controller/node.rs | 5 +---- crates/backend/src/main.rs | 12 +++--------- crates/esp-connect/src/main.rs | 4 +--- 3 files changed, 5 insertions(+), 16 deletions(-) diff --git a/crates/backend/src/controller/node.rs b/crates/backend/src/controller/node.rs index 2851e40..011f8ea 100644 --- a/crates/backend/src/controller/node.rs +++ b/crates/backend/src/controller/node.rs @@ -1,15 +1,12 @@ use crate::AppState; use actix_web::{ error::{ErrorBadRequest, ErrorInternalServerError}, - web, - web::Path, - Responder, + web, Responder, }; use chrono::Utc; use entity::{node, node_group, sensor_data}; use sea_orm::{entity::*, query::*, ActiveModelTrait, ActiveValue, EntityTrait}; use serde::{Deserialize, Serialize}; -use uuid::Uuid; #[derive(Serialize)] struct NodeWithSensorData { diff --git a/crates/backend/src/main.rs b/crates/backend/src/main.rs index fe78058..dd54492 100644 --- a/crates/backend/src/main.rs +++ b/crates/backend/src/main.rs @@ -1,6 +1,5 @@ use actix_web::{web, App, HttpServer}; use deku::prelude::*; -use entity::{node::ActiveModel, sensor_data}; use sea_orm::{ActiveModelTrait, ActiveValue, Database, DatabaseConnection}; use std::env; use tokio::{io::AsyncReadExt, net::TcpListener}; @@ -13,7 +12,6 @@ use routes::config; #[derive(Clone)] struct AppState { db: DatabaseConnection, - secret: String, } #[derive(DekuRead, DekuWrite, Debug)] @@ -34,7 +32,6 @@ async fn main() -> std::io::Result<()> { dotenvy::dotenv().ok(); let db_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set"); - let jwt_secret = env::var("TOKEN_SECRET").expect("TOKEN_SECRET must be set"); let conn = Database::connect(&db_url) .await @@ -42,10 +39,7 @@ async fn main() -> std::io::Result<()> { println!("Finished running migrations"); - let state = AppState { - db: conn.clone(), - secret: jwt_secret, - }; + let state = AppState { db: conn.clone() }; tokio::spawn(async { let db = conn; @@ -58,9 +52,9 @@ async fn main() -> std::io::Result<()> { println!("ESP CONNECTED"); let mut buffer = vec![0; 24]; loop { - if let Ok(size) = stream.read(&mut buffer).await { + if let Ok(_) = stream.read(&mut buffer).await { println!("{:#x?}", &buffer); - if let Ok((data, mut value)) = Data::from_bytes((&buffer, 0)) { + if let Ok((_, mut value)) = Data::from_bytes((&buffer, 0)) { println!("Received: {:#?}", value); value.mac.rotate_right(2); diff --git a/crates/esp-connect/src/main.rs b/crates/esp-connect/src/main.rs index 85f857a..3a98756 100644 --- a/crates/esp-connect/src/main.rs +++ b/crates/esp-connect/src/main.rs @@ -21,12 +21,10 @@ #![warn(rust_2018_idioms)] -use tokio::io::{AsyncReadExt, AsyncWriteExt}; +use tokio::io::AsyncReadExt; use tokio::net::TcpListener; use core::str; -use std::env; -use std::error::Error; #[tokio::main] async fn main() -> std::io::Result<()> {