diff --git a/leptosfmt.toml b/leptosfmt.toml deleted file mode 100644 index 10c879c..0000000 --- a/leptosfmt.toml +++ /dev/null @@ -1,4 +0,0 @@ -max_width = 80 -tab_spaces = 8 -indentation_style = "Tabs" -newline_style = "Unix" diff --git a/rust-analyzer.toml b/rust-analyzer.toml deleted file mode 100644 index 9eab123..0000000 --- a/rust-analyzer.toml +++ /dev/null @@ -1,2 +0,0 @@ -[rustfmt] -overrideCommand = ["leptosfmt", "--stdin", "--rustfmt"] diff --git a/rustfmt.toml b/rustfmt.toml index 82ce7eb..f4b1b83 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,4 +1,3 @@ -edition = "2024" -max_width = 80 -hard_tabs = true +max_width = 80 +hard_tabs = true tab_spaces = 8 diff --git a/src/bin/leptos.rs b/src/bin/leptos.rs index 69fd0a8..ceaf345 100644 --- a/src/bin/leptos.rs +++ b/src/bin/leptos.rs @@ -1,7 +1,9 @@ -use bkbh::leptos::cafe::Cafe; use leptos::prelude::*; +use bkbh::leptos::cafe::Cafe; fn main() { console_error_panic_hook::set_once(); - leptos::mount::mount_to_body(|| view! { }); + leptos::mount::mount_to_body( + || view! { } + ); } diff --git a/src/commands.rs b/src/commands.rs index 10fcf06..77f271c 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,7 +1,7 @@ +use tauri_sys::Error; +use tauri_sys::core::invoke; use crate::types::*; use std::collections::HashMap; -use tauri_sys::core::invoke; -use tauri_sys::Error; #[derive(serde::Serialize)] pub struct Swap { diff --git a/src/leptos/angel.rs b/src/leptos/angel.rs deleted file mode 100644 index ae56667..0000000 --- a/src/leptos/angel.rs +++ /dev/null @@ -1,8 +0,0 @@ -use leptos::prelude::*; - -#[component] -pub fn Angel() -> impl IntoView { - view! { -

Hi

- } -} diff --git a/src/leptos/cafe.rs b/src/leptos/cafe.rs index ab02620..db7a184 100644 --- a/src/leptos/cafe.rs +++ b/src/leptos/cafe.rs @@ -1,10 +1,10 @@ -use crate::commands::*; -use crate::types::*; -use leptos::form::FromFormData; use leptos::prelude::*; +use crate::commands::*; use leptos::task::spawn_local; use leptos::web_sys::FormData; +use leptos::form::FromFormData; use std::collections::HashMap; +use crate::types::*; #[component] pub fn Cafe() -> impl IntoView { @@ -13,7 +13,6 @@ pub fn Cafe() -> impl IntoView { - } } @@ -52,6 +51,18 @@ fn Reception(acc: ReadSignal) -> impl IntoView { } } +#[component] +fn StoreLogo(store: Store) -> impl IntoView { + view! { + ::into(&store)) + class="logo" + // FIXME: Implement fmt::Display for Store + alt=format!("{:?}", store) + /> + } +} + #[component] fn SwapButton(store: Store) -> impl IntoView { view! { @@ -63,7 +74,7 @@ fn SwapButton(store: Store) -> impl IntoView { } class="column" > - + } } @@ -78,7 +89,7 @@ fn StoreInput(store: Store) -> impl IntoView { impl IntoView { - view! { - ::into(&store)) - class="logo" - // FIXME: Implement fmt::Display for Store - alt=format!("{:?}", store) - /> - } -} diff --git a/src/lib.rs b/src/lib.rs index ef98862..3340bcd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,16 +1,16 @@ pub mod commands; -#[cfg(feature = "leptos")] -pub mod leptos; #[cfg(feature = "server")] pub mod server; +#[cfg(feature = "leptos")] +pub mod leptos; pub mod types; -#[cfg(all(feature = "tauri", feature = "server"))] +#[cfg(all(feature = "tauri", feature="server"))] #[cfg_attr(mobile, tauri::mobile_entry_point)] pub fn run() { - use server::app_state::AppState; use tauri::{Manager, State}; use tauri_plugin_fs::FsExt; + use server::app_state::AppState; use tokio::sync::Mutex; let state = AppState::new(); diff --git a/src/server/data_door.rs b/src/server/data_door.rs index ad8844c..555c9ac 100644 --- a/src/server/data_door.rs +++ b/src/server/data_door.rs @@ -1,8 +1,8 @@ use chrono::offset::Utc; use curl::{easy, easy::Easy2}; use rand::prelude::*; -use ring_compat::signature::ed25519::SigningKey; use rusqlite::{Connection, DatabaseName}; +use ring_compat::signature::ed25519::SigningKey; use tauri::{Manager, State}; use tokio::sync::Mutex; @@ -62,8 +62,7 @@ fn data_client(file: &str) -> Result, ()> { file ); client.url(&url).map_err(|_| ())?; - client.username(include_str!("cloud_user.txt")) - .map_err(|_| ())?; + client.username(include_str!("cloud_user.txt")).map_err(|_| ())?; client.http_auth(easy::Auth::new().auto(true)) .map_err(|_| ())?; client.ssl_cainfo_blob(include_bytes!("isrg-root-x1.pem")) @@ -77,7 +76,8 @@ fn put_client(file: &str, payload: &[u8]) -> Result, ()> { client.get_mut().1.extend_from_slice(payload); client.in_filesize(payload.len() as u64) .map_err(|e| println!("{:?}", e))?; - client.upload(true).map_err(|e| println!("{:?}", e))?; + client.upload(true) + .map_err(|e| println!("{:?}", e))?; Ok(client) } @@ -96,21 +96,22 @@ async fn push_key(id: &u64, key: &SigningKey) -> Result<(), ()> { let file = format!("{:016X}.key", id); let v_key = key.verifying_key(); let client = put_client(&file, v_key.as_ref())?; - let _perf = client.perform().map_err(|e| println!("{:?}", e))?; + let _perf = client.perform() + .map_err(|e| println!("{:?}", e))?; Ok(()) } fn push_db(id: &u64, db: &Connection, app: tauri::AppHandle) -> Result<(), ()> { let filename = format!("{:016X}.sqlite", id); - let path = app - .path() - .resolve(&filename, tauri::path::BaseDirectory::Temp) + let path = app.path().resolve(&filename, tauri::path::BaseDirectory::Temp) .map_err(|e| println!("{:?}", e))?; db.backup(DatabaseName::Main, &path, None) .map_err(|e| println!("{:?}", e))?; - let buf = std::fs::read(&path).map_err(|e| println!("{:?}", e))?; + let buf = std::fs::read(&path) + .map_err(|e| println!("{:?}", e))?; let client = put_client(&filename, buf.as_ref())?; - let _perf = client.perform().map_err(|e| println!("{:?}", e))?; + let _perf = client.perform() + .map_err(|e| println!("{:?}", e))?; Ok(()) } diff --git a/src/server/mod.rs b/src/server/mod.rs index 27a877c..87cf516 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -1,7 +1,7 @@ use chrono::offset::Utc; use std::collections::HashMap; -use tauri::State; use tokio::sync::Mutex; +use tauri::State; use crate::types::*; @@ -22,14 +22,14 @@ fn parse_inventory(data: HashMap) -> Result { match data.get(&format!("cafe-inventory-{}", s)) { None => (), Some(c) => { - let c = if c == "" { "0" } else { c }; + let c = if c == "" {"0"} else {c}; let Ok(count) = c.parse() else { println!("Invalid count '{}' for '{}' in inventory data.", c, s); continue; }; let v = VoucherInventory { store, count }; vouchers.push(v); - } + }, } } unimplemented!() @@ -47,10 +47,15 @@ pub async fn inventory( for v in inv.vouchers { state.db.execute( "INSERT INTO voucher_inventory VALUES ()", - (inv.acc, v.store, v.count, now), + ( + inv.acc, + v.store, + v.count, + now, + ), ) .map_err(|e| println!("{:?}", e))?; - } + }; Ok(()) } diff --git a/src/types.rs b/src/types.rs index 36e0800..fd2815b 100644 --- a/src/types.rs +++ b/src/types.rs @@ -1,6 +1,6 @@ #[cfg(feature = "server")] use rusqlite::{types::ToSqlOutput, ToSql}; -use serde::{Deserialize, Serialize}; +use serde::{Serialize, Deserialize}; #[derive(Clone, Copy, Debug, Serialize, Deserialize)] pub enum Store { @@ -43,10 +43,12 @@ impl std::str::FromStr for Cash { .map_err(|e| println!("{:?}", e))?; let f = match split.get(1) { None => 0, - Some(fs) => i64::from_str(&format!("00{}", fs)[0..2]) - .map_err(|e| println!("{:?}", e))?, + Some(fs) => i64::from_str( + &format!("00{}", fs)[0..2] + ) + .map_err(|e| println!("{:?}", e))?, }; - Ok(Cash(i * 100 + f)) + Ok(Cash(i*100+f)) } } @@ -105,8 +107,7 @@ impl std::fmt::Display for Account { match *self { Account::Sumpf => "Sumpf", Account::Heinersyndikat => "Heinersyndikat", - } - .fmt(f) + }.fmt(f) } }