fix warnings
This commit is contained in:
parent
fcf449ec8b
commit
e3e1c4a5b9
|
@ -1,15 +1,12 @@
|
||||||
use crate::AppState;
|
use crate::AppState;
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
error::{ErrorBadRequest, ErrorInternalServerError},
|
error::{ErrorBadRequest, ErrorInternalServerError},
|
||||||
web,
|
web, Responder,
|
||||||
web::Path,
|
|
||||||
Responder,
|
|
||||||
};
|
};
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use entity::{node, node_group, sensor_data};
|
use entity::{node, node_group, sensor_data};
|
||||||
use sea_orm::{entity::*, query::*, ActiveModelTrait, ActiveValue, EntityTrait};
|
use sea_orm::{entity::*, query::*, ActiveModelTrait, ActiveValue, EntityTrait};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct NodeWithSensorData {
|
struct NodeWithSensorData {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use actix_web::{web, App, HttpServer};
|
use actix_web::{web, App, HttpServer};
|
||||||
use deku::prelude::*;
|
use deku::prelude::*;
|
||||||
use entity::{node::ActiveModel, sensor_data};
|
|
||||||
use sea_orm::{ActiveModelTrait, ActiveValue, Database, DatabaseConnection};
|
use sea_orm::{ActiveModelTrait, ActiveValue, Database, DatabaseConnection};
|
||||||
use std::env;
|
use std::env;
|
||||||
use tokio::{io::AsyncReadExt, net::TcpListener};
|
use tokio::{io::AsyncReadExt, net::TcpListener};
|
||||||
|
@ -13,7 +12,6 @@ use routes::config;
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct AppState {
|
struct AppState {
|
||||||
db: DatabaseConnection,
|
db: DatabaseConnection,
|
||||||
secret: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(DekuRead, DekuWrite, Debug)]
|
#[derive(DekuRead, DekuWrite, Debug)]
|
||||||
|
@ -34,7 +32,6 @@ async fn main() -> std::io::Result<()> {
|
||||||
dotenvy::dotenv().ok();
|
dotenvy::dotenv().ok();
|
||||||
|
|
||||||
let db_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");
|
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)
|
let conn = Database::connect(&db_url)
|
||||||
.await
|
.await
|
||||||
|
@ -42,10 +39,7 @@ async fn main() -> std::io::Result<()> {
|
||||||
|
|
||||||
println!("Finished running migrations");
|
println!("Finished running migrations");
|
||||||
|
|
||||||
let state = AppState {
|
let state = AppState { db: conn.clone() };
|
||||||
db: conn.clone(),
|
|
||||||
secret: jwt_secret,
|
|
||||||
};
|
|
||||||
|
|
||||||
tokio::spawn(async {
|
tokio::spawn(async {
|
||||||
let db = conn;
|
let db = conn;
|
||||||
|
@ -58,9 +52,9 @@ async fn main() -> std::io::Result<()> {
|
||||||
println!("ESP CONNECTED");
|
println!("ESP CONNECTED");
|
||||||
let mut buffer = vec![0; 24];
|
let mut buffer = vec![0; 24];
|
||||||
loop {
|
loop {
|
||||||
if let Ok(size) = stream.read(&mut buffer).await {
|
if let Ok(_) = stream.read(&mut buffer).await {
|
||||||
println!("{:#x?}", &buffer);
|
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);
|
println!("Received: {:#?}", value);
|
||||||
|
|
||||||
value.mac.rotate_right(2);
|
value.mac.rotate_right(2);
|
||||||
|
|
|
@ -21,12 +21,10 @@
|
||||||
|
|
||||||
#![warn(rust_2018_idioms)]
|
#![warn(rust_2018_idioms)]
|
||||||
|
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::AsyncReadExt;
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
|
|
||||||
use core::str;
|
use core::str;
|
||||||
use std::env;
|
|
||||||
use std::error::Error;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
|
|
Loading…
Reference in a new issue