mirror of
https://github.com/Djeeberjr/fw-anwesenheit.git
synced 2026-04-30 18:49:09 +00:00
fixed git fuck up
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -1,15 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
use pm3::run_pm3;
|
||||
|
||||
mod parser;
|
||||
mod pm3;
|
||||
mod id_store;
|
||||
mod buzzer;
|
||||
|
||||
fn main() {
|
||||
run_pm3().unwrap();
|
||||
}
|
||||
=======
|
||||
use pm3::{pm3_mock, run_pm3};
|
||||
use tokio::sync::mpsc;
|
||||
use webserver::start_webserver;
|
||||
@@ -47,4 +35,3 @@ async fn main() {
|
||||
}
|
||||
}
|
||||
}
|
||||
>>>>>>> eb39b09632efb1568079352e3d639edc79df65fd
|
||||
|
||||
41
src/pm3.rs
41
src/pm3.rs
@@ -1,43 +1,3 @@
|
||||
<<<<<<< HEAD
|
||||
use std::error::Error;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::io::{self, BufRead};
|
||||
|
||||
pub fn run_pm3() -> Result<(), Box<dyn Error>> {
|
||||
let mut cmd = Command::new("stdbuf")
|
||||
.arg("-oL")
|
||||
.arg("pm3")
|
||||
.arg("-c")
|
||||
.arg("lf hitag reader -@")
|
||||
.stdout(Stdio::piped())
|
||||
.spawn()?;
|
||||
|
||||
let stdout = cmd.stdout.take().ok_or("Failed to get stdout")?;
|
||||
let reader = io::BufReader::new(stdout);
|
||||
|
||||
for line_result in reader.lines() {
|
||||
match line_result {
|
||||
Ok(line) => {
|
||||
let parse_result = super::parser::parse_line(&line);
|
||||
if let Some(uid) = parse_result {
|
||||
println!("UID: {}",uid);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("{}",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let status = cmd.wait().expect("Failed to wait on child");
|
||||
|
||||
if status.success() {
|
||||
Ok(())
|
||||
}else {
|
||||
Err("pm3 had non zero exit code".into())
|
||||
}
|
||||
}
|
||||
=======
|
||||
use std::error::Error;
|
||||
use std::io::{self, BufRead};
|
||||
use std::process::{Command, Stdio};
|
||||
@@ -100,4 +60,3 @@ pub async fn pm3_mock(tx: mpsc::Sender<String>) -> Result<(), Box<dyn Error>> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
>>>>>>> eb39b09632efb1568079352e3d639edc79df65fd
|
||||
|
||||
@@ -1,11 +1,35 @@
|
||||
use rocket::{get, routes};
|
||||
use rocket::{get, http::ContentType, response::content::RawHtml, routes};
|
||||
use rust_embed::Embed;
|
||||
use std::borrow::Cow;
|
||||
use std::ffi::OsStr;
|
||||
|
||||
#[derive(Embed)]
|
||||
#[folder = "web/dist"]
|
||||
struct Asset;
|
||||
|
||||
pub async fn start_webserver() -> Result<(), rocket::Error> {
|
||||
rocket::build().mount("/", routes![index]).launch().await?;
|
||||
rocket::build()
|
||||
.mount("/", routes![static_files,index])
|
||||
.launch()
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> &'static str {
|
||||
"Hello, world!"
|
||||
fn index() -> Option<RawHtml<Cow<'static, [u8]>>> {
|
||||
let asset = Asset::get("index.html")?;
|
||||
Some(RawHtml(asset.data))
|
||||
}
|
||||
|
||||
#[get("/<file..>")]
|
||||
fn static_files(file: std::path::PathBuf) -> Option<(ContentType, Vec<u8>)> {
|
||||
let filename = file.display().to_string();
|
||||
let asset = Asset::get(&filename)?;
|
||||
let content_type = file
|
||||
.extension()
|
||||
.and_then(OsStr::to_str)
|
||||
.and_then(ContentType::from_extension)
|
||||
.unwrap_or(ContentType::Bytes);
|
||||
|
||||
Some((content_type, asset.data.into_owned()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user