Cargo fmt

This commit is contained in:
Candifloss 2026-04-22 16:06:28 +05:30
parent 2f597030b5
commit e6737d3b4e
3 changed files with 29 additions and 38 deletions

View File

@ -1,7 +1,7 @@
use rusqlite::{Connection, Result}; use rusqlite::{Connection, Result};
use std::sync::Mutex; use std::sync::Mutex;
use rusqlite::types::Value; use rusqlite::types::Value;
pub struct Db { pub struct Db {
conn: Mutex<Connection>, conn: Mutex<Connection>,
@ -27,25 +27,25 @@ impl Db {
let col_count = stmt.column_count(); let col_count = stmt.column_count();
let rows_iter = stmt.query_map([], move |row| { let rows_iter = stmt.query_map([], move |row| {
let mut r = Vec::new(); let mut r = Vec::new();
for i in 0..col_count { for i in 0..col_count {
let val: Value = row.get(i)?; let val: Value = row.get(i)?;
let s = match val { let s = match val {
Value::Null => "<null>".to_string(), Value::Null => "<null>".to_string(),
Value::Integer(i) => i.to_string(), Value::Integer(i) => i.to_string(),
Value::Real(f) => f.to_string(), Value::Real(f) => f.to_string(),
Value::Text(t) => t, // already String Value::Text(t) => t, // already String
Value::Blob(_) => "<blob>".to_string(), Value::Blob(_) => "<blob>".to_string(),
}; };
r.push(s); r.push(s);
} }
Ok(r) Ok(r)
})?; })?;
let mut rows = Vec::new(); let mut rows = Vec::new();
for r in rows_iter { for r in rows_iter {

View File

@ -1,4 +1,4 @@
use axum::{routing::get, Router}; use axum::{Router, routing::get};
use clap::Parser; use clap::Parser;
use std::sync::Arc; use std::sync::Arc;
use tokio::net::TcpListener; use tokio::net::TcpListener;
@ -20,17 +20,11 @@ async fn main() {
let db = Arc::new(Db::open(&args.db).expect("db open failed")); let db = Arc::new(Db::open(&args.db).expect("db open failed"));
let app = Router::new() let app = Router::new().route("/", get(routes::index)).with_state(db);
.route("/", get(routes::index))
.with_state(db);
let listener = TcpListener::bind("127.0.0.1:8040") let listener = TcpListener::bind("127.0.0.1:8040").await.unwrap();
.await
.unwrap();
println!("http://127.0.0.1:8040"); println!("http://127.0.0.1:8040");
axum::serve(listener, app) axum::serve(listener, app).await.unwrap();
.await
.unwrap();
} }

View File

@ -1,9 +1,6 @@
use askama::Template; // REQUIRED use askama::Template; // REQUIRED
use axum::{ use axum::{extract::State, response::Html};
extract::State,
response::Html,
};
use std::sync::Arc; use std::sync::Arc;
use crate::db::Db; use crate::db::Db;